Skip to content

Instantly share code, notes, and snippets.

@Sh1Yo
Last active April 29, 2020 10:57
Show Gist options
  • Save Sh1Yo/b8a166a0e1cc286cf6c4a76345a51416 to your computer and use it in GitHub Desktop.
Save Sh1Yo/b8a166a0e1cc286cf6c4a76345a51416 to your computer and use it in GitHub Desktop.
Telegram notifications
#!/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