mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Fix inline-mode branch breaking after many commits from develop
This commit is contained in:
parent
acbbfabb27
commit
fede74398c
@ -80,7 +80,7 @@ class Dispatcher:
|
||||
),
|
||||
|
||||
(types.UpdateBotInlineQuery,):
|
||||
lambda upd, usr, cht: (utils.parse_inline_query(self.client, upd, usr), InlineQueryHandler)
|
||||
lambda upd, usr, cht: (pyrogram.InlineQuery._parse(self.client, upd, usr), InlineQueryHandler)
|
||||
}
|
||||
|
||||
self.update_parsers = {key: value for key_tuple, value in self.update_parsers.items() for key in key_tuple}
|
||||
|
@ -129,3 +129,6 @@ class BaseClient:
|
||||
|
||||
def get_chat_members_count(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def answer_inline_query(self, *args, **kwargs):
|
||||
pass
|
||||
|
@ -21,14 +21,16 @@ from pyrogram.client.ext import BaseClient
|
||||
|
||||
|
||||
class AnswerInlineQuery(BaseClient):
|
||||
def answer_inline_query(self,
|
||||
inline_query_id: str,
|
||||
results: list,
|
||||
cache_time: int = 300,
|
||||
is_personal: bool = None,
|
||||
next_offset: str = "",
|
||||
switch_pm_text: str = "",
|
||||
switch_pm_parameter: str = ""):
|
||||
def answer_inline_query(
|
||||
self,
|
||||
inline_query_id: str,
|
||||
results: list,
|
||||
cache_time: int = 300,
|
||||
is_personal: bool = None,
|
||||
next_offset: str = "",
|
||||
switch_pm_text: str = "",
|
||||
switch_pm_parameter: str = ""
|
||||
):
|
||||
# TODO: Docs
|
||||
return self.send(
|
||||
functions.messages.SetInlineBotResults(
|
||||
@ -39,8 +41,8 @@ class AnswerInlineQuery(BaseClient):
|
||||
private=is_personal or None,
|
||||
next_offset=next_offset or None,
|
||||
switch_pm=types.InlineBotSwitchPM(
|
||||
switch_pm_text,
|
||||
switch_pm_parameter
|
||||
text=switch_pm_text,
|
||||
start_param=switch_pm_parameter
|
||||
) if switch_pm_text else None
|
||||
)
|
||||
)
|
||||
|
@ -16,13 +16,20 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from typing import Tuple
|
||||
|
||||
import pyrogram
|
||||
from pyrogram.client.filters.filter import Filter
|
||||
from pyrogram.client.handlers.handler import Handler
|
||||
from ...ext import BaseClient
|
||||
|
||||
|
||||
class OnInlineQuery(BaseClient):
|
||||
def on_inline_query(self, filters=None, group: int = 0):
|
||||
def on_inline_query(
|
||||
self=None,
|
||||
filters=None,
|
||||
group: int = 0
|
||||
) -> callable:
|
||||
"""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`.
|
||||
@ -36,7 +43,10 @@ class OnInlineQuery(BaseClient):
|
||||
The group identifier, defaults to 0.
|
||||
"""
|
||||
|
||||
def decorator(func):
|
||||
def decorator(func: callable) -> Tuple[Handler, int]:
|
||||
if isinstance(func, tuple):
|
||||
func = func[0].callback
|
||||
|
||||
handler = pyrogram.InlineQueryHandler(func, filters)
|
||||
|
||||
if isinstance(self, Filter):
|
||||
|
@ -16,10 +16,17 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pyrogram.api.core import Object
|
||||
from typing import List
|
||||
|
||||
import pyrogram
|
||||
from pyrogram.api import types
|
||||
from ..bots.inline_query_result import InlineQueryResult
|
||||
from ..messages_and_media import Location
|
||||
from ..pyrogram_type import PyrogramType
|
||||
from ..user_and_chats import User
|
||||
|
||||
|
||||
class InlineQuery(Object):
|
||||
class InlineQuery(PyrogramType):
|
||||
"""This object represents an incoming inline query.
|
||||
When the user sends an empty query, your bot could return some default or trending results
|
||||
|
||||
@ -39,20 +46,56 @@ class InlineQuery(Object):
|
||||
location (:obj:`Location <pyrogram.Location>`. *optional*):
|
||||
Sender location, only for bots that request user location.
|
||||
"""
|
||||
ID = 0xb0700032
|
||||
__slots__ = ["id", "from_user", "query", "offset", "location"]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
client,
|
||||
id: str,
|
||||
from_user,
|
||||
query: str,
|
||||
offset: str,
|
||||
location=None,
|
||||
self,
|
||||
client: "pyrogram.client.ext.BaseClient",
|
||||
id: str,
|
||||
from_user: User,
|
||||
query: str,
|
||||
offset: str,
|
||||
location: Location = None
|
||||
):
|
||||
super().__init__(client)
|
||||
|
||||
self._client = client
|
||||
self.id = id
|
||||
self.from_user = from_user
|
||||
self.query = query
|
||||
self.offset = offset
|
||||
self.location = location
|
||||
|
||||
@staticmethod
|
||||
def _parse(client, inline_query: types.UpdateBotInlineQuery, users: dict) -> "InlineQuery":
|
||||
return InlineQuery(
|
||||
client=client,
|
||||
id=str(inline_query.query_id),
|
||||
from_user=User._parse(client, users[inline_query.user_id]),
|
||||
query=inline_query.query,
|
||||
offset=inline_query.offset,
|
||||
location=Location(
|
||||
longitude=inline_query.geo.long,
|
||||
latitude=inline_query.geo.lat,
|
||||
client=client
|
||||
) if inline_query.geo else None
|
||||
)
|
||||
|
||||
def answer(
|
||||
self,
|
||||
results: List[InlineQueryResult],
|
||||
cache_time: int = 300,
|
||||
is_personal: bool = None,
|
||||
next_offset: str = "",
|
||||
switch_pm_text: str = "",
|
||||
switch_pm_parameter: str = ""
|
||||
):
|
||||
return self._client.answer_inline_query(
|
||||
inline_query_id=self.id,
|
||||
results=results,
|
||||
cache_time=cache_time,
|
||||
is_personal=is_personal,
|
||||
next_offset=next_offset,
|
||||
switch_pm_text=switch_pm_text,
|
||||
switch_pm_parameter=switch_pm_parameter
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user