LANGUAGE/Python

Send Telegram Message via Telegram Bot

Hogeony 2019. 7. 16. 16:33

pip install python-telegram-bot

(note: do not command pip install telegram)

import telegram, sys
bot = telegram.Bot(token = 'YOUR_TOKEN')   #replace YOUR_TOKEN with yours

def send2bot(msg=sys.argv[0]):
    bot.sendMessage(chat_id='YOUR_ID', text=msg) #replace YOUR_ID with yours

send2bot()
send2bot('hello')