def receive_message(self, text, sender=None, chat=None, reply_to_message_id=None): if sender is None: sender = { 'id': 1, 'first_name': 'John', 'last_name': 'Doe', } if chat is None: chat = sender reply_to_message = None if reply_to_message_id is not None: reply_to_message = { 'message_id': reply_to_message_id, 'chat': chat, } self.bot.process_update( Update.from_dict({ 'update_id': self.received_id, 'message': { 'message_id': self.received_id, 'text': text, 'chat': chat, 'from': sender, 'reply_to_message': reply_to_message, } }) ) self.received_id += 1
def receive_update(self, sender=None, chat=None, left_chat_participant=None, new_chat_participant=None, group_chat_created=False): if sender is None: sender = { 'id': 1, 'first_name': 'John', 'last_name': 'Doe', } if chat is None: chat = sender self.bot.process_update( Update.from_dict({ 'update_id': self.received_id, 'message': { 'message_id': self.received_id, 'text': None, 'chat': chat, 'from': sender, 'left_chat_participant': left_chat_participant, 'new_chat_participant': new_chat_participant, 'group_chat_created': group_chat_created, } }) ) self.received_id += 1
def update(token): if token != tg_bot._token: abort(404, 'Not found: \'/update/%s\'' % token) tg_bot.process_update(Update.from_dict(request.json)) return None