Ejemplo n.º 1
0
    def _get_chat(self) -> Dict:
        """
        As Telegram changes where the chat object is located in the response,
        this method tries to be smart about finding it in the right place.
        """

        if 'callback_query' in self._update:
            query = self._update['callback_query']
            if 'message' in query:
                return query['message']['chat']
            else:
                return {'id': query['chat_instance']}
        elif 'inline_query' in self._update:
            return patch_dict(
                self._update['inline_query']['from'],
                is_inline_query=True,
            )
        elif 'message' in self._update:
            return self._update['message']['chat']
Ejemplo n.º 2
0
 async def serialize(self, request: Optional[Request] = None) -> Dict:
     return patch_dict(
         await super(InlineKeyboardSwitchInlineQueryButton,
                     self).serialize(request),
         switch_inline_query=True,
     )
Ejemplo n.º 3
0
 async def serialize(self, request: Optional[Request] = None) -> Dict:
     return patch_dict(
         await super(InlineKeyboardCallbackButton, self).serialize(request),
         callback_data=ujson.dumps(self.payload),
     )
Ejemplo n.º 4
0
 async def serialize(self, request: Optional[Request] = None) -> Dict:
     return patch_dict(
         await super(InlineKeyboardUrlButton, self).serialize(request),
         url=await self.make_url(request),
     )
Ejemplo n.º 5
0
 async def serialize(self, request: Optional[Request] = None) -> Dict:
     return patch_dict(
         await super(LocationKeyboardButton, self).serialize(request),
         request_location=True,
     )
Ejemplo n.º 6
0
 async def serialize(self, request: Optional[Request] = None) -> Dict:
     return patch_dict(
         await super(InlineKeyboardPayButton, self).serialize(request),
         pay=True,
     )