mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-17 21:22:40 +00:00
Add on_inline_query decorator
This commit is contained in:
parent
07cb14de61
commit
55cca00401
@ -19,6 +19,7 @@
|
|||||||
from .on_callback_query import OnCallbackQuery
|
from .on_callback_query import OnCallbackQuery
|
||||||
from .on_deleted_messages import OnDeletedMessages
|
from .on_deleted_messages import OnDeletedMessages
|
||||||
from .on_disconnect import OnDisconnect
|
from .on_disconnect import OnDisconnect
|
||||||
|
from .on_inline_query import OnInlineQuery
|
||||||
from .on_message import OnMessage
|
from .on_message import OnMessage
|
||||||
from .on_raw_update import OnRawUpdate
|
from .on_raw_update import OnRawUpdate
|
||||||
from .on_user_status import OnUserStatus
|
from .on_user_status import OnUserStatus
|
||||||
@ -30,6 +31,7 @@ class Decorators(
|
|||||||
OnCallbackQuery,
|
OnCallbackQuery,
|
||||||
OnRawUpdate,
|
OnRawUpdate,
|
||||||
OnDisconnect,
|
OnDisconnect,
|
||||||
OnUserStatus
|
OnUserStatus,
|
||||||
|
OnInlineQuery
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
50
pyrogram/client/methods/decorators/on_inline_query.py
Normal file
50
pyrogram/client/methods/decorators/on_inline_query.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrogram.
|
||||||
|
#
|
||||||
|
# Pyrogram is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrogram is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram.client.filters.filter import Filter
|
||||||
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
|
class OnInlineQuery(BaseClient):
|
||||||
|
def on_inline_query(self, filters=None, group: int = 0):
|
||||||
|
"""Use this decorator to automatically register a function for handling
|
||||||
|
inline queries. This does the same thing as :meth:`add_handler` using the
|
||||||
|
:class:`InlineQueryHandler`.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
filters (:obj:`Filters <pyrogram.Filters>`):
|
||||||
|
Pass one or more filters to allow only a subset of inline queries to be passed
|
||||||
|
in your function.
|
||||||
|
|
||||||
|
group (``int``, *optional*):
|
||||||
|
The group identifier, defaults to 0.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def decorator(func):
|
||||||
|
handler = pyrogram.InlineQueryHandler(func, filters)
|
||||||
|
|
||||||
|
if isinstance(self, Filter):
|
||||||
|
return pyrogram.InlineQueryHandler(func, self), group if filters is None else filters
|
||||||
|
|
||||||
|
if self is not None:
|
||||||
|
self.add_handler(handler, group)
|
||||||
|
|
||||||
|
return handler, group
|
||||||
|
|
||||||
|
return decorator
|
Loading…
Reference in New Issue
Block a user