Simplest way to send Telegram message by script - Printable Version

+- (https://diviera.com)
+-- Forum: Coding (https://diviera.com/forum-coding)
+--- Forum: Python (https://diviera.com/forum-python)
+--- Thread: Simplest way to send Telegram message by script (/thread-simplest-way-to-send-telegram-message-by-script)



Simplest way to send Telegram message by script - Janusz - 12-15-2020

This is the simplest way to send some notifications on smartphone by python script. No install extra module is needed.

First find and add BotFather on Telegram and send /newbot message. Follow instructions. Save new token from BotFather. 
[Image: ea9561af_tn.png]


Next, find and add IDBot and send /getid message. 
[Image: 03e0570c_tn.png]

import  urllib.request

token = '_PUT_YOUR_TOKEN_HERE_'
chatID = '_PUT_YOUR_CHATID_HERE_'

message = 'Diviera.com - place where PRO get heart attack'.replace(' ','%20')
urlMessage = 'https://api.telegram.org/bot' + token + '/sendMessage?chat_id=' + chatID + '&text=' + message

sendIt = urllib.request.urlopen(urlMessage)

print(sendIt.read())