Created
May 27, 2020 20:58
-
-
Save kavehbc/67ff669ff0dec5fced4a88d1c8c5e38b to your computer and use it in GitHub Desktop.
Python - Send a message via Telegram
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
import time | |
import requests | |
import urllib.parse | |
def sendTelegramMessage(message): | |
bot_token = 'API Token here' | |
bot_chatID = 'Chat ID here' | |
message = urllib.parse.query(message) | |
send_text = f'https://api.telegram.org/bot{bot_token}/sendMessage?chat_id={bot_chatID}&parse_mode=Markdown&text={message}' | |
response = requests.get(send_text) | |
return response.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment