最近学习一些telegram bot,记录一下
Installing
安装 python-telegram-bot 库
pip install python-telegram-bot --upgrade
安装完毕 > Successfully installed h11-0.14.0 httpcore-1.0.3 httpx-0.26.0 python-telegram-bot-20.8
bot 申请
私聊BotFather,
- /start
- /newbot
- Alright, a new bot. How are we going to call it? Please choose a name for your bot.
- IngressHomogeneous
- Good. Now let's choose a username for your bot. It must end in
bot
. Like this, for example: TetrisBot or tetris_bot. - IngressHomogeneousBot
- Done! Congratulations on your new bot. You will find it at t.me/IngressHomogeneousBot. 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.
妥善保存最后的 API Token。
1 | You can control me by sending these commands: |
获取我的 id
每个 tg 用户都有一串唯一标识,即为 user_id,可以私聊 @kmua 发送 /id 来获取它
跟着Your-first-Bot这个来就好了,理解的话可以参考使用Python写一个Telegram bot吧|Telegram bot教程。
感觉整体比较好理解,接下来就是赋予其灵魂了~
参考文章: