diff --git a/src/dumdum/server/state.py b/src/dumdum/server/state.py index ccd52cb..7b5bb48 100644 --- a/src/dumdum/server/state.py +++ b/src/dumdum/server/state.py @@ -34,8 +34,14 @@ def get_messages( *, before: int | None = None, after: int | None = None, + limit: int = 100, ) -> Sequence[Message]: - return self.message_cache.get_messages(channel_name, before=before, after=after) + return self.message_cache.get_messages( + channel_name, + before=before, + after=after, + limit=limit, + ) def add_message(self, message: Message) -> None: return self.message_cache.add_message(message) @@ -92,6 +98,7 @@ def get_messages( *, before: int | None = None, after: int | None = None, + limit: int = 100, ) -> Sequence[Message]: messages = list(self._channel_messages[channel_name]) @@ -103,7 +110,7 @@ def get_messages( i = bisect.bisect_right(messages, after, key=lambda m: m.id) messages = messages[:i] - return messages[-100:] + return messages[-limit:] def remove_message(self, channel_name: str, id: int) -> Message | None: messages = self._channel_messages[channel_name]