Initial commit

This commit is contained in:
BreadTube 2025-09-21 05:37:26 +09:00 committed by Corentin
commit 8ca93c1bab
7 changed files with 514 additions and 0 deletions

33
breadtube_bot/api.py Normal file
View file

@ -0,0 +1,33 @@
from enum import Enum
class ApiVersion(Enum):
V10 = 10
V9 = 9
V8 = 8
V7 = 7
V6 = 6
class ApiAction(Enum):
DELETE = 'DELETE'
GET = 'GET'
POST = 'POST'
class Api:
class Guild:
@staticmethod
def list_guilds(guild_id: int) -> tuple[ApiAction, str]:
return ApiAction.GET, f'/guilds/{guild_id}/channels'
class Message:
@staticmethod
def delete(channel_id: int, message_id: int) -> tuple[ApiAction, str]:
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')
return ApiAction.GET, f'/channels/{channel_id}/messages'