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:返回上一级列表
- 按照需求编辑即可。