import sys import requests import os def send(_msg: str): if len(_msg) == 0: return r = requests.post( url=os.environ['DISCORD_WEBHOOK'], data=f'content=```diff\n{requests.utils.quote(_msg)}```'.encode('utf-8'), headers = {'Content-Type': 'application/x-www-form-urlencoded'} ) r.raise_for_status() msg = '' for line in sys.stdin: if len(msg + line) >= 2000: send(msg) msg = '' else: msg += line send(msg)