コード例 #1
0
ファイル: client.py プロジェクト: hwipl/nuqql-matrixd
    def get_buddies(self, online: bool) -> None:
        """
        Get roster/buddy list
        """

        # if we are offline, there are no buddies
        if self.client.status == "offline":
            return

        # if only online wanted, skip because no matrix room is "online"
        if online:
            return

        # get buddies/rooms
        rooms = self.client.get_rooms()
        for room in rooms.values():
            name = escape_name(room.display_name)

            # use special status for group chats
            status = "GROUP_CHAT"

            # send buddy message
            msg = Message.buddy(self.account, room.room_id, name, status)
            self.account.receive_msg(msg)

        # handle pending room invites as temporary buddies
        invites = self.client.get_invites()
        for invite in invites.values():
            room_id, room_name, _sender, _sender_name, _tstamp = invite
            status = "GROUP_CHAT_INVITE"

            # send buddy message
            msg = Message.buddy(self.account, room_id, room_name, status)
            self.account.receive_msg(msg)
コード例 #2
0
ファイル: main.py プロジェクト: hwipl/nuqql-based
async def _get_buddies(acc: Optional["Account"], _cmd: Callback,
                       params: Tuple) -> str:
    """
    Get buddy list. For testing, this simply returns a single buddy list for
    all accounts.
    """

    # filter online users?
    online = False
    if params:
        online = params[0]

    # no test buddies are online, return empty list if only online wanted
    if online:
        return ""

    # construct buddy messages
    result = ""
    assert acc
    for buddy in TEST_BUDDIES:
        result += Message.buddy(acc, buddy, "", "")

    return result