def update_message_content_opened( controller: Controller, update: Dict[str, Any] ) -> None: chat_id = update["chat_id"] message_id = update["message_id"] controller.model.msgs.update_msg_content_opened(chat_id, message_id) controller.render_msgs()
def update_delete_messages(controller: Controller, update: Dict[str, Any]) -> None: if not update["is_permanent"]: log.debug("Ignoring deletiong becuase not permanent: %s", update) return chat_id = update["chat_id"] msg_ids = update["message_ids"] controller.model.msgs.remove_messages(chat_id, msg_ids) controller.render_msgs()
def update_message_edited(controller: Controller, update: Dict[str, Any]): chat_id = update["chat_id"] message_id = update["message_id"] edit_date = update["edit_date"] controller.model.msgs.update_msg(chat_id, message_id, edit_date=edit_date) current_chat_id = controller.model.current_chat_id if current_chat_id == chat_id: controller.render_msgs()
def update_message_send_succeeded(controller: Controller, update): chat_id = update["message"]["chat_id"] msg_id = update["old_message_id"] controller.model.msgs.add_message(chat_id, update["message"]) controller.model.msgs.remove_message(chat_id, msg_id) current_chat_id = controller.model.current_chat_id if current_chat_id == chat_id: controller.render_msgs()
def update_new_message(controller: Controller, update: Dict[str, Any]) -> None: msg = MsgProxy(update["message"]) controller.model.msgs.add_message(msg.chat_id, msg.msg) current_chat_id = controller.model.current_chat_id if current_chat_id == msg.chat_id: controller.render_msgs() if msg.file_id and msg.size and msg.size <= max_download_size: controller.download(msg.file_id, msg.chat_id, msg["id"]) controller.notify_for_message(msg.chat_id, msg)
def update_message_send_succeeded(controller: Controller, update: Dict[str, Any]) -> None: chat_id = update["message"]["chat_id"] msg_id = update["old_message_id"] controller.model.msgs.add_message(chat_id, update["message"]) controller.model.msgs.remove_messages(chat_id, [msg_id]) current_chat_id = controller.model.current_chat_id if current_chat_id == chat_id: controller.render_msgs()
def update_message_content(controller: Controller, update: Dict[str, Any]): chat_id = update["chat_id"] message_id = update["message_id"] controller.model.msgs.update_msg(chat_id, message_id, content=update["new_content"]) current_chat_id = controller.model.current_chat_id if current_chat_id == chat_id: controller.render_msgs()
def update_file(controller: Controller, update: Dict[str, Any]) -> None: file_id = update["file"]["id"] local = update["file"]["local"] chat_id, msg_id = controller.model.downloads.get(file_id, (None, None)) if chat_id is None or msg_id is None: log.warning("Can't find information about file with file_id=%s", file_id) return msg = controller.model.msgs.msgs[chat_id].get(msg_id) if not msg: return proxy = MsgProxy(msg) proxy.local = local controller.render_msgs() if proxy.is_downloaded: controller.model.downloads.pop(file_id)
def update_file(controller: Controller, update): log.info("update_file: %s", update) file_id = update["file"]["id"] local = update["file"]["local"] chat_id, msg_id = controller.model.downloads.get(file_id, (None, None)) if chat_id is None: log.warning("Can't find information about file with file_id=%s", file_id) return msgs = controller.model.msgs.msgs[chat_id] for msg in msgs: if msg["id"] == msg_id: proxy = MsgProxy(msg) proxy.local = local controller.render_msgs() if proxy.is_downloaded: controller.model.downloads.pop(file_id) break
def update_supergroup(controller: Controller, update: Dict[str, Any]) -> None: supergroup = update["supergroup"] controller.model.users.supergroups[supergroup["id"]] = supergroup controller.render_msgs()
def update_basic_group(controller: Controller, update: Dict[str, Any]) -> None: basic_group = update["basic_group"] controller.model.users.groups[basic_group["id"]] = basic_group controller.render_msgs()
def update_delete_messages(controller: Controller, update: Dict[str, Any]): chat_id = update["chat_id"] msg_ids = update["message_ids"] for msg_id in msg_ids: controller.model.msgs.remove_message(chat_id, msg_id) controller.render_msgs()
def update_delete_messages(controller: Controller, update: Dict[str, Any]) -> None: chat_id = update["chat_id"] msg_ids = update["message_ids"] controller.model.msgs.remove_messages(chat_id, msg_ids) controller.render_msgs()