Created
December 30, 2021 15:21
-
-
Save FloPinguin/d7f0b6a27fbb8b4303e22a25f64dd195 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_telegram(msg, log=False): | |
r = None | |
try: | |
token = "" | |
if log: | |
token = "" | |
for start in range(0, len(msg), 4000): | |
data = {'chat_id': 123456789, 'text': msg[start:start+4000]} | |
r = requests.post("https://api.telegram.org/bot" + token + "/sendMessage", timeout=30, data=data) | |
r.raise_for_status() | |
except Exception as e: | |
out = "" | |
if r is not None: | |
out = " (" + r.text + ")" | |
print("Could not send telegram message \"" + msg + "\": " + str(e) + out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment