本文整理匯總了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