Telegram(非正式簡稱TG或電報)是跨平台的即時通信軟件,其客戶端是自由及開放源代碼軟件,但服務器端是專有軟件。用戶可以相互交換加密與自毀消息(類似於“閱后即焚”),發送照片、影片等所有類型文件。官方提供手機版(Android、iOS、Windows Phone)、桌面版(Windows、macOS、Linux)和網頁版 [1] 等多種平台客戶端;同時官方開放應用程序接口(API),因此擁有許多第三方的客戶端可供選擇 [2] ,其中多款內置中文。(轉載自百度百科)
准備工作
- 一台外網服務器(可選,如果不需要保持24小時在線那么就不要)
- 可以訪問telegram的網絡環境
注冊機器人賬號
- 打開telegram搜索“BotFather”
- 輸入消息窗口敲入以下命令
-
/newbot
- 應該會顯示:Alright, a new bot. How are we going to call it?Please choose a name for your bot.
- 發送機器人ID,可以隨便填,但最好和你的用途有關
- 然后會提示Good. Now let's choose a username for your bot. It must end in bot. Like this, for example: TetrisBot or tetris_bot.
- 這時發送你給機器人設置的ID(和微信號類似),但必須以_bot結尾
- 如果顯示:Sorry, this username is invalid.就需要更改
- 直到顯示:Done! Congratulations on your new bot. You will find it at t.me/xxxxx_bot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
- Use this token to access the HTTP API: 【這里是API TOKEN,很重要,保存好且不要泄露】
- Keep your token secure and store it safely, it can be used by anyone to control your bot.
- For a description of the Bot API, see this page: https://core.telegram.org/bots/api
編輯機器人信息(可選)
- 和上面一樣,發送指令
-
/mybots
- 之后會顯示創建的所有機器人賬號ID,選擇剛才創建的那一個
- 會顯示六個選項:API Token:顯示 api 密鑰 Edit Bot:編輯機器人 Bot Settings:機器人設置 Payments:支付 Delete Bot:刪除機器人(銷毀機器人賬號) Back...ots List:返回上一級列表
- 按照需求編輯即可。