@@ -43,6 +43,12 @@ class InlineQuery(Object, Update):
4343 offset (``str``):
4444 Offset of the results to be returned, can be controlled by the bot.
4545
46+ chat_type (``str``, *optional*):
47+ Type of the chat, from which the inline query was sent.
48+ Can be either "sender" for a private chat with the inline query sender, "private", "group", "supergroup", or
49+ "channel". The chat type should be always known for requests sent from official clients and most
50+ third-party clients, unless the request was sent from a secret chat.
51+
4652 location (:obj:`~pyrogram.types.Location`. *optional*):
4753 Sender location, only for bots that request user location.
4854
@@ -59,6 +65,7 @@ def __init__(
5965 from_user : "types.User" ,
6066 query : str ,
6167 offset : str ,
68+ chat_type : str ,
6269 location : "types.Location" = None ,
6370 matches : List [Match ] = None
6471 ):
@@ -68,16 +75,32 @@ def __init__(
6875 self .from_user = from_user
6976 self .query = query
7077 self .offset = offset
78+ self .chat_type = chat_type
7179 self .location = location
7280 self .matches = matches
7381
7482 @staticmethod
7583 def _parse (client , inline_query : raw .types .UpdateBotInlineQuery , users : dict ) -> "InlineQuery" :
84+ peer_type = inline_query .peer_type
85+ chat_type = None
86+
87+ if isinstance (peer_type , raw .types .InlineQueryPeerTypeSameBotPM ):
88+ chat_type = "sender"
89+ elif isinstance (peer_type , raw .types .InlineQueryPeerTypePM ):
90+ chat_type = "private"
91+ elif isinstance (peer_type , raw .types .InlineQueryPeerTypeChat ):
92+ chat_type = "group"
93+ elif isinstance (peer_type , raw .types .InlineQueryPeerTypeMegagroup ):
94+ chat_type = "supergroup"
95+ elif isinstance (peer_type , raw .types .InlineQueryPeerTypeBroadcast ):
96+ chat_type = "channel"
97+
7698 return InlineQuery (
7799 id = str (inline_query .query_id ),
78100 from_user = types .User ._parse (client , users [inline_query .user_id ]),
79101 query = inline_query .query ,
80102 offset = inline_query .offset ,
103+ chat_type = chat_type ,
81104 location = types .Location (
82105 longitude = inline_query .geo .long ,
83106 latitude = inline_query .geo .lat ,
0 commit comments