Source code for hydrogram.raw.functions.messages.set_inline_bot_results

#  Hydrogram - Telegram MTProto API Client Library for Python
#  Copyright (C) 2023-present Hydrogram <https://hydrogram.org>
#
#  This file is part of Hydrogram.
#
#  Hydrogram 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.
#
#  Hydrogram 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 Hydrogram.  If not, see <http://www.gnu.org/licenses/>.

from io import BytesIO

from hydrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from hydrogram.raw.core import TLObject
from hydrogram import raw
from typing import List, Optional, Any

# # # # # # # # # # # # # # # # # # # # # # # #
#               !!! WARNING !!!               #
#          This is a generated file!          #
# All changes made in this file will be lost! #
# # # # # # # # # # # # # # # # # # # # # # # #


[docs] class SetInlineBotResults(TLObject): # type: ignore """Answer an inline query, for bots only Details: - Layer: ``181`` - ID: ``BB12A419`` Parameters: query_id (``int`` ``64-bit``): Unique identifier for the answered query results (List of :obj:`InputBotInlineResult <hydrogram.raw.base.InputBotInlineResult>`): Vector of results for the inline query cache_time (``int`` ``32-bit``): The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. gallery (``bool``, *optional*): Set this flag if the results are composed of media files private (``bool``, *optional*): Set this flag if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query next_offset (``str``, *optional*): Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes. switch_pm (:obj:`InlineBotSwitchPM <hydrogram.raw.base.InlineBotSwitchPM>`, *optional*): If passed, clients will display a button on top of the remaining inline result list with the specified text, that switches the user to a private chat with the bot and sends the bot a start message with a certain parameter. switch_webview (:obj:`InlineBotWebView <hydrogram.raw.base.InlineBotWebView>`, *optional*): If passed, clients will display a button on top of the remaining inline result list with the specified text, that switches the user to the specified inline mode mini app. Returns: ``bool`` """ __slots__: List[str] = ["query_id", "results", "cache_time", "gallery", "private", "next_offset", "switch_pm", "switch_webview"] ID = 0xbb12a419 QUALNAME = "functions.messages.SetInlineBotResults" def __init__(self, *, query_id: int, results: List["raw.base.InputBotInlineResult"], cache_time: int, gallery: Optional[bool] = None, private: Optional[bool] = None, next_offset: Optional[str] = None, switch_pm: "raw.base.InlineBotSwitchPM" = None, switch_webview: "raw.base.InlineBotWebView" = None) -> None: self.query_id = query_id # long self.results = results # Vector<InputBotInlineResult> self.cache_time = cache_time # int self.gallery = gallery # flags.0?true self.private = private # flags.1?true self.next_offset = next_offset # flags.2?string self.switch_pm = switch_pm # flags.3?InlineBotSwitchPM self.switch_webview = switch_webview # flags.4?InlineBotWebView @staticmethod def read(b: BytesIO, *args: Any) -> "SetInlineBotResults": flags = Int.read(b) gallery = True if flags & (1 << 0) else False private = True if flags & (1 << 1) else False query_id = Long.read(b) results = TLObject.read(b) cache_time = Int.read(b) next_offset = String.read(b) if flags & (1 << 2) else None switch_pm = TLObject.read(b) if flags & (1 << 3) else None switch_webview = TLObject.read(b) if flags & (1 << 4) else None return SetInlineBotResults(query_id=query_id, results=results, cache_time=cache_time, gallery=gallery, private=private, next_offset=next_offset, switch_pm=switch_pm, switch_webview=switch_webview) def write(self, *args) -> bytes: b = BytesIO() b.write(Int(self.ID, False)) flags = 0 flags |= (1 << 0) if self.gallery else 0 flags |= (1 << 1) if self.private else 0 flags |= (1 << 2) if self.next_offset is not None else 0 flags |= (1 << 3) if self.switch_pm is not None else 0 flags |= (1 << 4) if self.switch_webview is not None else 0 b.write(Int(flags)) b.write(Long(self.query_id)) b.write(Vector(self.results)) b.write(Int(self.cache_time)) if self.next_offset is not None: b.write(String(self.next_offset)) if self.switch_pm is not None: b.write(self.switch_pm.write()) if self.switch_webview is not None: b.write(self.switch_webview.write()) return b.getvalue()