当前位置: 首页>>代码示例>>Python>>正文


Python ext.RegexHandler方法代码示例

本文整理汇总了Python中telegram.ext.RegexHandler方法的典型用法代码示例。如果您正苦于以下问题:Python ext.RegexHandler方法的具体用法?Python ext.RegexHandler怎么用?Python ext.RegexHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在telegram.ext的用法示例。


在下文中一共展示了ext.RegexHandler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register_handlers

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import RegexHandler [as 别名]
def register_handlers(dispatcher, mode):
    assert mode in ('production', 'test')

    dispatcher.add_handler(MessageHandler(
        Filters.status_update.new_chat_members, handle_new_chat_members
    ))
    dispatcher.add_handler(CommandHandler(
        ['start', 'help'], handle_start_help
    ))
    dispatcher.add_handler(CommandHandler('stat', handle_stat))
    dispatcher.add_handler(CommandHandler(
        ['daysandbox_set', 'daysandbox_get'], handle_set_get
    ))
    dispatcher.add_handler(RegexHandler(
        r'^/setlogformat ', handle_setlogformat, channel_post_updates=True
    ))
    dispatcher.add_handler(CommandHandler('setlog', handle_setlog))
    dispatcher.add_handler(CommandHandler('unsetlog', handle_unsetlog))
    dispatcher.add_handler(MessageHandler(
        Filters.all, partial(handle_any_message, mode), edited_updates=True
    )) 
开发者ID:lorien,项目名称:daysandbox_bot,代码行数:23,代码来源:daysandbox_bot.py

示例2: _add_link_handler

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import RegexHandler [as 别名]
def _add_link_handler(self):
        self.dispatcher.add_handler(RegexHandler(
            utl.comp("^/_([a-zA-Z0-9]*)__([\w]*)$"), self._cmd_link_callback)) 
开发者ID:Endogen,项目名称:OpenCryptoBot,代码行数:5,代码来源:telegrambot.py

示例3: main

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import RegexHandler [as 别名]
def main():
    """
    Main function.
    This function handles the conversation flow by setting
    states on each step of the flow. Each state has its own
    handler for the interaction with the user.
    """
    global LANG
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(telegram_token)

    # Get the dispatcher to register handlers:
    dp = updater.dispatcher

    # Add conversation handler with predefined states:
    conv_handler = ConversationHandler(
        entry_points=[CommandHandler('start', start)],

        states={
            SET_LANG: [RegexHandler('^(ES|EN)$', set_lang)],

            MENU: [CommandHandler('menu', menu)],

            SET_STAT: [RegexHandler(
                        '^({}|{}|{}|{})$'.format(
                            send_report['ES'], view_map['ES'],
                            view_faq['ES'], view_about['ES']),
                        set_state),
                       RegexHandler(
                        '^({}|{}|{}|{})$'.format(
                            send_report['EN'], view_map['EN'],
                            view_faq['EN'], view_about['EN']),
                        set_state)],

            LOCATION: [MessageHandler(Filters.location, location),
                       CommandHandler('menu', menu)]
        },

        fallbacks=[CommandHandler('cancel', cancel),
                   CommandHandler('help', help)]
    )

    dp.add_handler(conv_handler)

    # Log all errors:
    dp.add_error_handler(error)

    # Start DisAtBot:
    updater.start_polling()

    # Run the bot until the user presses Ctrl-C or the process
    # receives SIGINT, SIGTERM or SIGABRT:
    updater.idle() 
开发者ID:RodolfoFerro,项目名称:DisAtBot,代码行数:55,代码来源:DisAtBot.py


注:本文中的telegram.ext.RegexHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。