def get_chat_id_by_hash(self, chat_hash): try: chat = Chat.get((Chat.hash == chat_hash)) return chat.chat_id except Chat.DoesNotExist: return None
def send_to_chat(self, chat_hash): if self.status_publish: try: chat = Chat.get((Chat.hash == chat_hash)) send_to_chat(self.get_output(), chat.chat_id) except Chat.DoesNotExist: return False return True
def append_chat(chat_id): """ Append chat unless it haven't been used :param chat_id: Telegram chat id :return: unique chat hash (as route) """ try: chat = Chat.get((Chat.chat_id == chat_id)) hash = chat.hash except Chat.DoesNotExist: hash = generate_hash() chat = Chat.create(hash=hash, chat_id=chat_id, notifications_mask=255) chat.save() return hash