Telegram Bot 建立紀錄

常用功能記錄起來

1.建立Telegram Bot
2.獲取bot Token
3.獲取聊天室chat_id
4.發送訊息測試

1.建立Telegram Bot
搜尋@botfather

建立newbot

2.獲取bot Token
建立bot後系統會產生bot的API token

之後可以從botfather去設定bot

3.獲取聊天室chat_id
先把bot 加入群組(group)或者是頻道(channel)
透過 https://api.telegram.org/bot/getUpdates
這邊獲取chat_id

 

4.發送訊息測試
這邊是透過 https://github.com/rahiel/telegram-send 來發送訊息
此專案需要先安裝 python3 & pip3以上
bot group 設定驗證

#telegram-send --config group1.conf --configure-group
Talk with the BotFather on Telegram (https://telegram.me/BotFather), create a bot and insert the token
❯ 這邊輸入Telegram Bot API Token
Connected with xxx_bot.

Please add xxx_bot to your group
and send the following message to the group: /57690@xxx_bot  (這邊在群組輸入)

Congratulations XXXXX! 
telegram-send is now ready for use!

發送群組訊息

#telegram-send --config group1.conf "test message"
Facebook Comments