【笔记】创建TelegramBot

前言

创建TelegramBot

创建机器人

  • 访问@BotFather机器人,根据提示创建自己的机器人

通过/start查看使用说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
I can help you create and manage Telegram bots. If you're new to the Bot API, please see the manual.

You can control me by sending these commands:

/newbot - create a new bot
/mybots - edit your bots

Edit Bots
/setname - change a bot's name
/setdescription - change bot description
/setabouttext - change bot about info
/setuserpic - change bot profile photo
/setcommands - change the list of commands
/deletebot - delete a bot

Bot Settings
/token - generate authorization token
/revoke - revoke bot access token
/setinline - toggle inline mode
/setinlinegeo - toggle inline location requests
/setinlinefeedback - change inline feedback settings
/setjoingroups - can your bot be added to groups?
/setprivacy - toggle privacy mode in groups

Web Apps
/myapps - edit your web apps
/newapp - create a new web app
/listapps - get a list of your web apps
/editapp - edit a web app
/deleteapp - delete an existing web app

Games
/mygames - edit your games
/newgame - create a new game
/listgames - get a list of your games
/editgame - edit a game
/deletegame - delete an existing game

通过/newbot创建一个机器人

1
Alright, a new bot. How are we going to call it? Please choose a name for your bot.

根据提示输入机器人名称,会作为机器人账号用户名

1
Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.

根据提示输入机器人外链名,会作为分享链接的名称,必须以_bot结尾

<name>:机器人外链名
0000000000:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:API Key

1
2
3
4
5
6
7
Done! Congratulations on your new bot. You will find it at t.me/<name>_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:
0000000000:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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

创建完成,在代码中通过API Key操作TelegramBot

查看机器人

通过/mybots查看所有机器人

删除机器人

通过/mybots查看所有机器人,选择一个要操作的机器人->Delete Bot->Yes, delete the bot->Yes, I'm 100% sure!

完成

参考文献

姿势小王子的博客
Telegram官方文档