环境安装

也可以通过pip安装
pip install python-telegram-bot
或者通过源码安装

$ git clone https://github.com/python-telegram-bot/python-telegram-bot --recursive
$ cd python-telegram-bot
$ python setup.py install

一、注册机器人获取api

关注@BotFather用户

I can help you create and manage Telegram bots. If you're new to the Bot API, please see the manual (https://core.telegram.org/bots).

You can control me by sending these commands:

/newbot - 创建一个机器人账号
/mybots - 修改急切五年配置

(第一次输入的为name,第二次输入的为bot的 id)

二、把机器人拉入频道(必须设置为管理员)

三、运用机器人推送消息

下面为发送文本、网址和图片的方法

项目地址:
https://github.com/SaltNego/telegram_python_bot/tree/master

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐