从零开始搭建Telegram机器人(一)—— 注册机器人账号


Telegram(非正式简称TG电报)是跨平台的即时通信软件,其客户端是自由及开放源代码软件,但服务器端是专有软件。用户可以相互交换加密与自毁消息(类似于“阅后即焚”),发送照片、影片等所有类型文件。官方提供手机版(AndroidiOSWindows Phone)、桌面版(WindowsmacOSLinux)和网页版 [1]  等多种平台客户端;同时官方开放应用程序接口(API),因此拥有许多第三方的客户端可供选择 [2]  ,其中多款内置中文。(转载自百度百科)

准备工作

  • 一台外网服务器(可选,如果不需要保持24小时在线那么就不要)
  • 可以访问telegram的网络环境

注册机器人账号

  1. 打开telegram搜索“BotFather”
  2. 输入消息窗口敲入以下命令
  3. /newbot
  4. 应该会显示:Al­right, a new bot. How are we go­ing to call it?Please choose a name for your bot.
  5. 发送机器人ID,可以随便填,但最好和你的用途有关
  6. 然后会提示Good. Now let's choose a user­name for your bot. It must end in bot. Like this, for ex­am­ple: Tetris­Bot or tetris_bot.
  7. 这时发送你给机器人设置的ID(和微信号类似),但必须以_bot结尾
  8. 如果显示:Sorry, this username is invalid.就需要更改
  9. 直到显示: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.
  10. Use this to­ken to ac­cess the HTTP API: 【这里是API TOKEN,很重要,保存好且不要泄露】
  11. Keep your to­ken se­cure and store it safely, it can be used by any­one to con­trol your bot.
  12. For a de­scrip­tion of the Bot API, see this page: https://core.telegram.org/bots/api

编辑机器人信息(可选)

  1. 和上面一样,发送指令
  2. /mybots
  3. 之后会显示创建的所有机器人账号ID,选择刚才创建的那一个
  4. 会显示六个选项:API To­ken:显示 api 密钥 Edit Bot:编辑机器人 Bot Set­tings:机器人设置 Pay­ments:支付 Delete Bot:删除机器人(销毁机器人账号) Back...ots List:返回上一级列表
  5. 按照需求编辑即可。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM