一个电报机器人库,带有简单的路由装饰器。

telebot的Python项目详细描述


一个电报机器人库,带有简单的路由装饰器。

目前一项工作正在进行中,现在做的不多,但会注册并发送消息。

示例设置

from telebot import TeleBot

app = TeleBot(__name__)


@app.route('/command ?(.*)')
def example_command(message, cmd):
    chat_dest = message['chat']['id']
    msg = "Command Recieved: {}".format(cmd)

    app.send_message(chat_dest, msg)


@app.route('(?!/).+')
def parrot(message):
   chat_dest = message['chat']['id']
   user_msg = message['text']

   msg = "Parrot Says: {}".format(user_msg)
   app.send_message(chat_dest, msg)


if __name__ == '__main__':
    app.config['api_key'] = 'xxxxxxxx:enterYourBotKeyHereToTest'
    app.poll(debug=True)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java同步块与私有不可变对象和同步方法的差异   OracleDataSource、OracleUCP、Commons DBCP和Tomcat连接池之间的java差异?   java在文本文件中写入对象   java访问web服务   如何用java代码并行读取拼花地板文件   spring是否可以将运行时未知的Avro消息转换为特定的Java类   具有复杂对象的java Spring数据MongoDB addToSet()   java ArrayList是否删除元素,是否向下移动列表?   Vaadin中按钮的java多行标题不起作用   java为什么要使用@PropertySource而不是PropertyPlaceHolderConfigure?   java如何检查网站链接是否有数据(图片)或网站是否无效?   java如何禁用对jsp页面的直接访问?   用java实现matlab递归文件夹读取。伊奥。文件   为什么是java。伊奥。FileDescriptor的构造函数是公共的吗?   在java中关闭扫描程序时无法访问的代码?   搜索Java模拟退火接受概率