Last active
April 29, 2020 10:57
-
-
Save Sh1Yo/b8a166a0e1cc286cf6c4a76345a51416 to your computer and use it in GitHub Desktop.
Telegram notifications
This file contains 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
#!/usr/bin/python3 | |
#Usage - "telegram {file}" or "telegram '{message}'" | |
import requests, sys | |
from requests.adapters import HTTPAdapter | |
from requests.exceptions import ConnectionError | |
group_id = "" | |
bot_token = "" | |
f = "" | |
try: | |
f = open(sys.argv[1], "r").read() | |
except: | |
f = sys.argv[1] | |
adapter = HTTPAdapter(max_retries=10) | |
session = requests.Session() | |
session.mount('https://api.telegram.org', adapter) | |
try: | |
a = session.get("https://api.telegram.org/bot"+bot_token+"/sendMessage?chat_id="+group_id+"&parse_mode=HTML&text="+f, timeout=160) | |
print(a.text) | |
except: | |
print("[!] telegram", f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment