Ejemplo n.º 1
0
 def get_most_recent_incoming_chat(self, after=-1) -> Optional["ChatNode"]:
     r = self._db_read_one(
         """
         SELECT uuid
         FROM Chats
         WHERE speaker != ? AND time >= ?
         ORDER BY time DESC
         LIMIT 1
         """,
         self.self_memid,
         after,
     )
     if r:
         return ChatNode(self, r[0])
     else:
         return None
Ejemplo n.º 2
0
 def get_chat_by_id(self, memid: str) -> "ChatNode":
     return ChatNode(self, memid)
Ejemplo n.º 3
0
 def get_recent_chats(self, n=1) -> List["ChatNode"]:
     """Return a list of at most n chats"""
     r = self._db_read("SELECT uuid FROM Chats ORDER BY time DESC LIMIT ?",
                       n)
     return [ChatNode(self, m) for m, in reversed(r)]
Ejemplo n.º 4
0
 def add_chat(self, speaker_memid: str, chat: str) -> str:
     return ChatNode.create(self, speaker_memid, chat)