當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。