Config scan from bot channel implementation

This commit is contained in:
BreadTube 2025-09-23 22:48:35 +09:00 committed by Corentin
commit 157e8c1b17
6 changed files with 453 additions and 34 deletions

View file

@ -1,7 +1,7 @@
from enum import Enum
from typing import TypedDict
from breadtube_bot.objects import Overwrite
from breadtube_bot.objects import MessageReference, Overwrite
class ApiVersion(Enum):
@ -116,7 +116,7 @@ class Api:
tts: bool # true if this is a TTS message
# embeds: list[Embeded] # Up to 10 rich embeds (up to 6000 characters)
# allowed_mentions: MentionObject # Allowed mentions for the message
# message_reference: MessageReference # Include to make your message a reply or a forward
message_reference: MessageReference # Include to make your message a reply or a forward
# components: list[MessageComponent] # Components to include with the message
sticker_ids: list[int] # IDs of up to 3 stickers in the server to send in the message
# files[n]: FileContents # Contents of the file being sent. See Uploading Files
@ -136,7 +136,11 @@ class Api:
return ApiAction.DELETE, f'/channels/{channel_id}/messages/{message_id}'
@staticmethod
def list_by_channel(channel_id: int, limit: int | None = None) -> tuple[ApiAction, str]:
if limit is not None and not (0 < limit <= 100): # noqa: PLR2004
raise RuntimeError('Cannot list messages by channel with limit outside [0, 100] range')
def list_by_channel(channel_id: int) -> tuple[ApiAction, str]:
return ApiAction.GET, f'/channels/{channel_id}/messages'
class ListMessageParams(TypedDict, total=False):
around: int # Get messages around this message ID
before: int # Get messages before this message ID
after: int # Get messages after this message ID
limit: int # Max number of messages to return (1-100), default=50