_002_water_meter_control.py 文件源码

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

项目:coolq-telegram-bot 作者: jqqqqqqqqqq 项目源码 文件源码
def add_channel(bot: telegram.Bot,
                update: telegram.Update):
    if update.message.forward_from_chat:
        if update.message.forward_from_chat.type != 'channel':  # it seems forward_from_chat can only be channels
            update.message.reply_text(
                'Message type error. Please forward me a message from channel, or use /cancel to stop')
            return
        if update.message.forward_from_chat.id not in global_vars.filter_list['channels']:
            global_vars.filter_list['channels'].append(update.message.forward_from_chat.id)
            save_data()
            update.message.reply_text('Okay, please send me another, or use /cancel to stop')
        else:
            update.message.reply_text('Already in list. Send me another or use /cancel to stop')
        return CHANNEL
    else:
        if update.message.text == '/cancel':
            update.message.reply_text('Done.')
            return ConversationHandler.END
        else:
            update.message.reply_text(
                'Message type error. Please forward me a message from channel, or use /cancel to stop')
            return CHANNEL
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号