Ejemplo n.º 1
0
    def get_chat_by_id(self, memid: str) -> "ChatNode":
        """Return ChatNode, given memid

        Args:
            memid (string): Memory ID
        """
        return ChatNode(self, memid)
Ejemplo n.º 2
0
    def get_recent_chats(self, n=1) -> List["ChatNode"]:
        """Return a list of at most n chats

        Args:
            n (int): number of recent 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.º 3
0
    def add_chat(self, speaker_memid: str, chat: str) -> str:
        """Create a new chatNode

        Args:
            speaker_memid (string): memory ID of speaker
            chat (string): text representing chat
        """
        return ChatNode.create(self, speaker_memid, chat)
Ejemplo n.º 4
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.º 5
0
    def get_most_recent_incoming_chat(self, after=-1) -> Optional["ChatNode"]:
        """Get the most recent chat that came in since 'after'

        Args:
            after (int): Marks the beginning of time window (from now)
        """
        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.º 6
0
 def get_chat_by_id(self, memid: str) -> "ChatNode":
     return ChatNode(self, memid)
Ejemplo n.º 7
0
 def add_chat(self, speaker_memid: str, chat: str) -> str:
     return ChatNode.create(self, speaker_memid, chat)