Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions kick/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,32 @@ async def fetch_stream_url_and_key(self) -> DestinationInfo:
data = await self.http.fetch_stream_destination_url_and_key()
return DestinationInfo(data=data)

async def get_messages(self, chatroom_id: int, /) -> list[Message]:
"""
|coro|

Fetches messages from a chatroom.

Parameters
-----------
chatroom_id: int
The ID of the chatroom to fetch messages from

Raises
-----------
HTTPException
Failed to fetch messages
NotFound
Chatroom with provided ID was not found

Returns
-----------
list[Message]
List of messages from the chatroom
"""
data = await self.http.get_messages(chatroom_id)
return [Message(data=msg, http=self.http) for msg in data["data"]["messages"]]

def dispatch(self, event_name: str, *args, **kwargs) -> None:
event_name = f"on_{event_name}"

Expand Down
10 changes: 5 additions & 5 deletions kick/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def slug(self) -> str:
"""

return self._data["slug"]

@property
def username(self) -> str:
"""
Expand Down Expand Up @@ -201,20 +201,20 @@ def references(self) -> PartialMessage | None:
return PartialMessage(data=data, http=self.http)

@property
def chatroom_id(self) -> int:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you re-add this as a depreciated alias of chat_id?

def chat_id(self) -> int:
"""
The id of the chatroom the message was sent in
"""

return self._data["chatroom_id"]
return self._data["chat_id"]

@property
def chatroom(self) -> Chatroom | PartialChatroom | None:
"""
The chatroom the message was sent in.
"""

return self.http.client.get_chatroom(self.chatroom_id)
return self.http.client.get_chatroom(self.chat_id)

@property
def content(self) -> str:
Expand Down Expand Up @@ -244,4 +244,4 @@ def __eq__(self, other: object) -> bool:
return isinstance(other, self.__class__) and other.id == self.id

def __repr__(self) -> str:
return f"<Message id={self.id!r} chatroom={self.chatroom_id!r} author={self.author!r}>"
return f"<Message id={self.id!r} chatroom={self.chat_id!r} author={self.author!r}>"
2 changes: 1 addition & 1 deletion kick/types/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AuthorPayload(TypedDict):

class BaseMessagePayload(TypedDict):
id: str
chatroom_id: int
chat_id: int
content: str
created_at: str
sender: AuthorPayload
Expand Down