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


Python ext.CallbackQueryHandler方法代码示例

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


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

示例1: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, api_key, fallback):
        self.compiler = HackerRankAPI(api_key=api_key)
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('compiler', self.compilers)],
            allow_reentry=True,
            states={
                LANG: [CallbackQueryHandler(self.lang, pass_user_data=True, pattern=r'\w*comp1\b')],
                CODE: [CallbackQueryHandler(self.code, pass_user_data=True, pattern=r'\w*so1\b')],
                DECODE: [MessageHandler(Filters.text, self.decode, pass_user_data=True)],
                TESTCASES: [MessageHandler(Filters.text, self.testcases, pass_user_data=True)],
                OTHER: [MessageHandler(Filters.text, self.other, pass_user_data=True)],
                FILE: [MessageHandler(Filters.document, self.filer, pass_user_data=True)],
                FILETEST: [MessageHandler(Filters.document, self.filetest, pass_user_data=True)]
            },
            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:18,代码来源:compiler.py

示例2: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, mount_point, fallback):
        if not os.path.exists(mount_point + 'codeforces.json'):
            shutil.copy('codeforces.json', mount_point + 'codeforces.json')
        with open(mount_point + 'codeforces.json', 'r') as codeforces:
            self.qcf = json.load(codeforces)
        self.conv_handler10 = ConversationHandler(
            entry_points=[CommandHandler('randomcf', self.randomcf)],
            allow_reentry=True,
            states={
                QSELCF: [CallbackQueryHandler(self.qselcf, pattern=r'\w*cf1\b')]
            },
            fallbacks=[fallback]
        )

    # START OF CONVERSATION HANDLER FOR GETTING RANDOM QUESTION FROM CODEFORCES
    # FUNCTION TO GET INPUT ABOUT THE TYPE OF QUESTION FROM USER 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:18,代码来源:codeforces.py

示例3: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, mount_point, fallback):
        self.mount_point = mount_point
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('subscribe', self.subscribe)],
            allow_reentry=True,
            states={
                SUBSEL: [CallbackQueryHandler(self.subsel, pattern=r'\w*sub3\b', pass_user_data=True)],
                SUB: [CallbackQueryHandler(self.sub, pattern=r'\w*sub2\b', pass_user_data=True)]
            },
            fallbacks=[fallback]
        )
        self.conv_handler1 = ConversationHandler(
            entry_points=[CommandHandler('unsubscribe', self.unsubsel)],
            allow_reentry=True,
            states={
                UNSUB: [CallbackQueryHandler(self.unsub, pattern=r'\w*unsub4\b')]
            },
            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:21,代码来源:ques_of_the_day.py

示例4: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, mount_point, fallback):
        self.mount_point = mount_point
        self.utility = Utility(mount_point)
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('ranklist', self.ranklist)],
            allow_reentry=True,
            states={

                SELECTION: [CallbackQueryHandler(self.selection, pattern=r'\w*sel1\b')],
                HOLO: [CallbackQueryHandler(self.holo, pattern=r'\w*list6\b')],
                SOLO: [CallbackQueryHandler(self.solo, pattern=r'\w*list7\b')],
                POLO: [MessageHandler(Filters.text, self.polo, pass_user_data=True)],
                XOLO: [CallbackQueryHandler(self.xolo, pass_user_data=True, pattern=r'\w*list8\b')]
            },

            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:19,代码来源:ranklist.py

示例5: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, mount_point, fallback):
        self.mount_point = mount_point
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('register', self.register)],
            allow_reentry=True,
            states={

                NAME: [MessageHandler(Filters.text, self.name, pass_user_data=True)],

                JUDGE: [CallbackQueryHandler(self.judge, pass_user_data=True, pattern=r'\w*reg1\b')],

                HANDLE: [MessageHandler(Filters.text, self.handle, pass_user_data=True)]
            },

            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:18,代码来源:register.py

示例6: __register_handlers

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __register_handlers(self):
    functional.apply_fn(
      self.message_handlers.items(), 
      lambda h: self.__add_handler(MessageHandler(
        h[0], 
        lambda b, u, **kwargs: self.__pre__hook(h[1], b, u, **kwargs)))
    )

    functional.apply_fn(
      self.command_handlers.items(), 
      lambda h: self.__add_handler(ChannelCommandHandler(
        h[0], 
        lambda b, u, **kwargs: self.__pre__hook(h[1][0], b, u, **kwargs),
        filters=h[1][1]))
    )

    functional.apply_fn(
      self.callback_handlers.items(),
      lambda h: self.__add_handler(CallbackQueryHandler(h[1]))
    )

# Decorators for adding callbacks 
开发者ID:charslab,项目名称:TranscriberBot,代码行数:24,代码来源:bot.py

示例7: add_towel_mode

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def add_towel_mode(upd: Updater, handlers_group: int):
    logger.info("registering towel-mode handlers")
    dp = upd.dispatcher

    # catch all new users and drop the towel
    dp.add_handler(MessageHandler(Filters.status_update.new_chat_members, catch_new_user),
                   handlers_group)

    # check for reply or remove messages
    dp.add_handler(MessageHandler(
        Filters.group & ~Filters.status_update, catch_reply),
        handlers_group
    )

    # "i am a bot button"
    dp.add_handler(CallbackQueryHandler(i_am_a_bot_btn), handlers_group)

    # ban quarantine users, if time is gone
    upd.job_queue.run_repeating(ban_user, interval=60, first=60, context={
        "chat_id": get_config()["GROUP_CHAT_ID"]
    }) 
开发者ID:egregors,项目名称:vldc-bot,代码行数:23,代码来源:towel_mode.py

示例8: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, token):
        self._bot = telegram.Bot(token)
        self._updater = Updater(bot=self._bot)

        dp = self._updater.dispatcher
        dp.add_handler(CommandHandler("start", self._start_cmd))
        dp.add_handler(CommandHandler("reset", self._reset_cmd))
        dp.add_handler(CommandHandler("stop", self._reset_cmd))
        dp.add_handler(CommandHandler("help", self._help_cmd))
        dp.add_handler(CommandHandler("text", self._text_cmd))
        dp.add_handler(CommandHandler("evaluation_start", self._evaluation_start_cmd))
        dp.add_handler(CommandHandler("evaluation_end", self._evaluation_end_cmd))

        dp.add_handler(MessageHandler(Filters.text, self._echo_cmd))

        dp.add_handler(CallbackQueryHandler(self._eval_keyboard))
        dp.add_error_handler(self._error)

        self._users_fsm = {}
        self._users = {}
        self._text_and_qas = load_text_and_qas('data/squad-25-qas.json')
        self._text_ind = 0
        self._evaluation = {}
        self._eval_suggestions = None 
开发者ID:sld,项目名称:convai-bot-1337,代码行数:26,代码来源:telegram_main.py

示例9: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, cc_dict, fallback):
        self.cc_dict = cc_dict
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('randomcc', self.randomcc)],
            allow_reentry=True,
            states={

                QSELCC: [CallbackQueryHandler(self.qselcc, pattern=r'\w*cc1\b')]

            },
            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:14,代码来源:codechef.py

示例10: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, mount_point, fallback):
        self.mount_point = mount_point
        self.fallback = fallback
        self.rating_obj = ratings.Rating()
        self.utility = Utility(mount_point)
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('update', self.updatesel)],
            allow_reentry=True,
            states={
                UPDA: [CallbackQueryHandler(self.updasel, pattern=r'\w*upd5\b')]
            },
            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:15,代码来源:update_rank_list.py

示例11: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, fallback):
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('geeksforgeeks', self.gfg)],
            allow_reentry=True,
            states={
                GFG1: [CallbackQueryHandler(self.gfg1, pass_user_data=True, pattern=r'\w*gfg1\b')],
                GFG2: [CallbackQueryHandler(self.gfg2, pass_user_data=True, pattern='^.*gfg2.*$')],
                GFG3: [CallbackQueryHandler(self.gfg3, pass_user_data=True, pattern='^.*gfg3.*$')]
            },
            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:13,代码来源:geeks_for_geeks.py

示例12: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, clist_user_name, clist_api_key, mount_point, bot, fallback):
        self.clist_user_name = clist_user_name
        self.clist_api_key = clist_api_key
        self.bot = bot
        self.ong = None
        self.upc = None
        self.mount_point = mount_point
        self.utility = ContestUtility(mount_point)
        self.jobstores = {
            'default': SQLAlchemyJobStore(url='sqlite:///' + mount_point + 'coders1.db')
        }
        self.schedule = BackgroundScheduler(jobstores=self.jobstores)
        self.schedule.start()
        self.conv_handler = ConversationHandler(
            entry_points=[CommandHandler('upcoming', self.upcoming)],
            allow_reentry=True,
            states={
                SCHED: [CallbackQueryHandler(self.remind, pattern=r"^[0-9]*$")]
            },
            fallbacks=[fallback]
        )
        self.conv_handler1 = ConversationHandler(
            entry_points=[CommandHandler('dontRemindMe', self.removeRemind)],
            allow_reentry=True,
            states={
                REMNOTI: [CallbackQueryHandler(self.remnoti, pattern=r'^.*notiplz.*$')]
            },

            fallbacks=[fallback]
        ) 
开发者ID:Gotham13121997,项目名称:superCodingBot,代码行数:32,代码来源:competitions.py

示例13: main

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def main():
    test_handler = CommandHandler("test", test)
    start_handler = CommandHandler("start", start, pass_args=True)

    help_handler = CommandHandler("help", get_help)
    help_callback_handler = CallbackQueryHandler(help_button, pattern=r"help_")

    settings_handler = CommandHandler("settings", get_settings)
    settings_callback_handler = CallbackQueryHandler(settings_button, pattern=r"stngs_")

    donate_handler = CommandHandler("donate", donate)
    migrate_handler = MessageHandler(Filters.status_update.migrate, migrate_chats)

    # dispatcher.add_handler(test_handler)
    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(help_handler)
    dispatcher.add_handler(settings_handler)
    dispatcher.add_handler(help_callback_handler)
    dispatcher.add_handler(settings_callback_handler)
    dispatcher.add_handler(migrate_handler)
    dispatcher.add_handler(donate_handler)

    # dispatcher.add_error_handler(error_callback)

    if WEBHOOK:
        LOGGER.info("Using webhooks.")
        updater.start_webhook(listen="0.0.0.0",
                              port=PORT,
                              url_path=TOKEN)

        if CERT_PATH:
            updater.bot.set_webhook(url=URL + TOKEN,
                                    certificate=open(CERT_PATH, 'rb'))
        else:
            updater.bot.set_webhook(url=URL + TOKEN)

    else:
        LOGGER.info("Using long polling.")
        updater.start_polling(timeout=15, read_latency=4)

    updater.idle() 
开发者ID:TGExplore,项目名称:Marie-2.0-English,代码行数:43,代码来源:__main__.py

示例14: main

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def main():
    global dispatcher, updater, Token, Blacklist, admin
    load_config()
    updater = Updater(Token)
    dispatcher = updater.dispatcher
    fwd_text_handler = MessageHandler(Filters.all & (~Filters.command),
                                      read_text_message)
    ban_user_handler = CommandHandler('ban', ban_user)
    unban_user_handler = CommandHandler('unban', unban_user)
    callback_query_handler = CallbackQueryHandler(answer_session)
    dispatcher.add_handler(callback_query_handler)
    dispatcher.add_handler(fwd_text_handler)
    dispatcher.add_handler(ban_user_handler)
    dispatcher.add_handler(unban_user_handler)
    updater.start_polling() 
开发者ID:Tooruchan,项目名称:simple-forwarder-bot,代码行数:17,代码来源:main.py

示例15: __init__

# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import CallbackQueryHandler [as 别名]
def __init__(self, params):
        """
        A Telegram bot interface for Macaw.

        Args:
            params(dict): A dict of parameters. The params 'logger' and 'bot_token' are mandatory.
        """
        super().__init__(params)
        self.logger = self.params['logger']

        self.MAX_MSG_LEN = 1000  # maximum number of characters in each response message.
        self.MAX_OPTION_LEN = 30  # maximum number of characters in each clickable option text.

        # Starting the bot by creating the Updater.
        # Make sure to set use_context=True to use the new context based callbacks
        # If you don't have a bot_token, add 'botfather' to your personal Telegram account and follow the instructions
        # to get a token for your bot.
        self.updater = Updater(self.params['bot_token'], use_context=True)
        self.dp = self.updater.dispatcher

        # Telegram command handlers (e.g., /start)
        self.dp.add_handler(CommandHandler('start', self.start))
        self.dp.add_handler(CommandHandler('help', self.help))

        # Telegram message handlers
        self.dp.add_handler(MessageHandler(Filters.text, self.request_handler))
        self.dp.add_handler(MessageHandler(Filters.voice, self.voice_request_handler))
        self.dp.add_handler(CallbackQueryHandler(self.button_click_handler))

        # logging all errors
        self.dp.add_error_handler(self.error) 
开发者ID:microsoft,项目名称:macaw,代码行数:33,代码来源:telegram.py


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