Skip to content

chat

Contains classes relating to the Roblox chat.

ChatProvider

Provides information and data related to the Roblox chat system.

Source code in roblox/chat.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class ChatProvider:
    """
    Provides information and data related to the Roblox chat system.
    """

    def __init__(self, client: Client):
        """
        Arguments:
            client: The Client for getting information about chat.
        """
        self._client: Client = client

    def __repr__(self):
        return f"<{self.__class__.__name__}>"

    async def get_unread_conversation_count(self) -> int:
        """
        Gets the authenticated user's unread conversation count.

        Returns: 
            The user's unread conversation count.
        """
        unread_response = await self._client.requests.get(
            url=self._client.url_generator.get_url("chat", "v2/get-unread-conversation-count")
        )
        unread_data = unread_response.json()
        return unread_data["count"]

    async def get_settings(self) -> ChatSettings:
        """
        Gets the authenticated user's chat settings.

        Returns: 
            The user's chat settings.
        """
        settings_response = await self._client.requests.get(
            url=self._client.url_generator.get_url("chat", "v2/chat-settings")
        )
        settings_data = settings_response.json()
        return ChatSettings(data=settings_data)

    def get_user_conversations(self) -> PageNumberIterator:
        """
        Gets the user's conversations.

        Returns: 
            The user's conversations as a PageNumberIterator.
        """
        return PageNumberIterator(
            client=self._client,
            url=self._client.url_generator.get_url("chat", "v2/get-user-conversations"),
            handler=lambda client, data: Conversation(client=client, data=data)
        )

__init__(client)

Parameters:

Name Type Description Default
client Client

The Client for getting information about chat.

required
Source code in roblox/chat.py
45
46
47
48
49
50
def __init__(self, client: Client):
    """
    Arguments:
        client: The Client for getting information about chat.
    """
    self._client: Client = client

get_settings() async

Gets the authenticated user's chat settings.

Returns:

Type Description
ChatSettings

The user's chat settings.

Source code in roblox/chat.py
68
69
70
71
72
73
74
75
76
77
78
79
async def get_settings(self) -> ChatSettings:
    """
    Gets the authenticated user's chat settings.

    Returns: 
        The user's chat settings.
    """
    settings_response = await self._client.requests.get(
        url=self._client.url_generator.get_url("chat", "v2/chat-settings")
    )
    settings_data = settings_response.json()
    return ChatSettings(data=settings_data)

get_unread_conversation_count() async

Gets the authenticated user's unread conversation count.

Returns:

Type Description
int

The user's unread conversation count.

Source code in roblox/chat.py
55
56
57
58
59
60
61
62
63
64
65
66
async def get_unread_conversation_count(self) -> int:
    """
    Gets the authenticated user's unread conversation count.

    Returns: 
        The user's unread conversation count.
    """
    unread_response = await self._client.requests.get(
        url=self._client.url_generator.get_url("chat", "v2/get-unread-conversation-count")
    )
    unread_data = unread_response.json()
    return unread_data["count"]

get_user_conversations()

Gets the user's conversations.

Returns:

Type Description
PageNumberIterator

The user's conversations as a PageNumberIterator.

Source code in roblox/chat.py
81
82
83
84
85
86
87
88
89
90
91
92
def get_user_conversations(self) -> PageNumberIterator:
    """
    Gets the user's conversations.

    Returns: 
        The user's conversations as a PageNumberIterator.
    """
    return PageNumberIterator(
        client=self._client,
        url=self._client.url_generator.get_url("chat", "v2/get-user-conversations"),
        handler=lambda client, data: Conversation(client=client, data=data)
    )

ChatSettings

Represents the authenticated user's Roblox chat settings.

Attributes:

Name Type Description
chat_enabled bool

Whether chat is enabled for the user.

is_active_chat_user bool

Whether the user is an active chat user. New accounts are active by default and become inactive if they do not send any messages over a period of time.

is_connect_tab_enabled bool

Whether the Connect tab is enabled for this user.

Source code in roblox/chat.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class ChatSettings:
    """
    Represents the authenticated user's Roblox chat settings.

    Attributes:
        chat_enabled: Whether chat is enabled for the user.
        is_active_chat_user: Whether the user is an active chat user. New accounts are active by default and become
                             inactive if they do not send any messages over a period of time.
        is_connect_tab_enabled: Whether the Connect tab is enabled for this user.
    """

    def __init__(self, data: dict):
        """
        Arguments:
            data: The raw input data.
        """
        self.chat_enabled: bool = data["chatEnabled"]
        self.is_active_chat_user: bool = data["isActiveChatUser"]
        self.is_connect_tab_enabled: bool = data["isConnectTabEnabled"]

    def __repr__(self):
        return f"<{self.__class__.__name__} chat_enabled={self.chat_enabled} is_active_chat_user={self.is_active_chat_user} is_connect_tab_enabled={self.is_connect_tab_enabled}>"

__init__(data)

Parameters:

Name Type Description Default
data dict

The raw input data.

required
Source code in roblox/chat.py
27
28
29
30
31
32
33
34
def __init__(self, data: dict):
    """
    Arguments:
        data: The raw input data.
    """
    self.chat_enabled: bool = data["chatEnabled"]
    self.is_active_chat_user: bool = data["isActiveChatUser"]
    self.is_connect_tab_enabled: bool = data["isConnectTabEnabled"]