Created
July 4, 2023 05:26
-
-
Save amirulabu/13025a41b74f5b66155c4aa4c68883fe to your computer and use it in GitHub Desktop.
python3.9 compatible send message to telegram script
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 | |
#!/usr/bin/python3 | |
import http.client, json, sys | |
conn = http.client.HTTPSConnection("api.telegram.org") | |
body = {'chat_id': xxx, 'text': " ".join(sys.argv[1:]) } | |
jsondata = json.dumps(body) | |
jsondataasbytes = jsondata.encode('utf-8') | |
headers = {"Content-type": "application/json"} | |
conn.request("POST", | |
"/botxxxxxxxxxxxaddyourtelegrambottokenherexxxx/sendMessage", | |
jsondataasbytes, headers) | |
r1 = conn.getresponse() | |
print(r1.status, r1.reason) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment