cust_filters.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:tgbot 作者: PaulSonOfLars 项目源码 文件源码
def filters(bot, update):
    chat = update.effective_chat
    msg = update.effective_message
    args = msg.text.split(None, 2)  # use python's maxsplit to separate Cmd, keyword, and reply_text

    keyword = args[1]
    is_sticker = False
    is_document = False

    if len(args) >= 3:
        content = args[2]

    elif msg.reply_to_message and msg.reply_to_message.sticker:
        content = msg.reply_to_message.sticker.file_id
        is_sticker = True

    elif msg.reply_to_message and msg.reply_to_message.document:
        content = msg.reply_to_message.document.file_id
        is_document = True

    else:
        return

    save_filter(chat.id, keyword, content, is_sticker, is_document)
    update.effective_message.reply_text("Handler {} added!".format(keyword))
    raise DispatcherHandlerStop
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号