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']
async def serialize(self, request: Optional[Request] = None) -> Dict: return patch_dict( await super(InlineKeyboardSwitchInlineQueryButton, self).serialize(request), switch_inline_query=True, )
async def serialize(self, request: Optional[Request] = None) -> Dict: return patch_dict( await super(InlineKeyboardCallbackButton, self).serialize(request), callback_data=ujson.dumps(self.payload), )
async def serialize(self, request: Optional[Request] = None) -> Dict: return patch_dict( await super(InlineKeyboardUrlButton, self).serialize(request), url=await self.make_url(request), )
async def serialize(self, request: Optional[Request] = None) -> Dict: return patch_dict( await super(LocationKeyboardButton, self).serialize(request), request_location=True, )
async def serialize(self, request: Optional[Request] = None) -> Dict: return patch_dict( await super(InlineKeyboardPayButton, self).serialize(request), pay=True, )