本文整理汇总了Python中telegram.ext.InlineQueryHandler方法的典型用法代码示例。如果您正苦于以下问题:Python ext.InlineQueryHandler方法的具体用法?Python ext.InlineQueryHandler怎么用?Python ext.InlineQueryHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类telegram.ext
的用法示例。
在下文中一共展示了ext.InlineQueryHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import InlineQueryHandler [as 别名]
def register(dispatcher):
dispatcher.add_handler(InlineQueryHandler(inline_query))
示例2: __init__
# 需要导入模块: from telegram import ext [as 别名]
# 或者: from telegram.ext import InlineQueryHandler [as 别名]
def __init__(self, bot_token, bot_db):
self.db = bot_db
self.token = bot_token
read_timeout = Cfg.get("telegram", "read_timeout")
connect_timeout = Cfg.get("telegram", "connect_timeout")
kwargs = dict()
if read_timeout:
kwargs["read_timeout"] = read_timeout
if connect_timeout:
kwargs["connect_timeout"] = connect_timeout
try:
self.updater = Updater(bot_token, request_kwargs=kwargs)
except InvalidToken as e:
cls_name = f"Class: {type(self).__name__}"
logging.error(f"{repr(e)} - {cls_name}")
exit("ERROR: Bot token not valid")
self.job_queue = self.updater.job_queue
self.dispatcher = self.updater.dispatcher
# Load classes in folder 'plugins'
self._load_plugins()
# Handler for files downloads (plugins)
mh = MessageHandler(Filters.document, self._download)
self.dispatcher.add_handler(mh)
# Handler for command-links
self._add_link_handler()
# Handler for inline-mode
inline_handler = InlineQueryHandler(self._inline)
self.dispatcher.add_handler(inline_handler)
# Handle all Telegram related errors
self.dispatcher.add_error_handler(self._handle_tg_errors)
# Refresh cache periodically
self._refresh_cache()
# Check for updates periodically
self._update_check()
# Start the bot