announcement-bot/bot/model.py

63 lines
1.6 KiB
Python

from dataclasses import dataclass
from datetime import datetime
@dataclass
class WatchGuild:
'''WatchGuild represents a Discord guild as stored in the database.
Attributes:
id: Guild ID as given by Discord
name: Name of the guild at the time of adding the bot
'''
id: int
name: str
join_date: datetime
@dataclass
class WatchChannel:
'''WatchChannel represents a Discord channel being watched for new messages
Attributes:
id: Channel ID as given by Discord
name: Name of the channel at the time of registration
register_date: Datetime object when the channel was registered
guild: WatchGuild object of which the channel belongs to
'''
id: int
name: str
register_date: datetime
guild: WatchGuild
@dataclass
class WatchUser:
'''WatchUser represents a Discord user who has sent a message in a watched channel.
Attributes:
id: User ID as given by Discord
name: Nickname in the server at the time of latest message recorded
'''
id: int
name: str
@dataclass
class WatchMessage:
'''WatchMessage represents a Discord message sent in a watched channel.
Attributes:
id: Message ID as given by Discord.
contents: Raw contents of the message.
published_date: Datetime object representing when the message was sent.
author: WatchUser who sent the message.
channel: WatchChannel in which the message was sent.
guild: WatchGuild in which the message was sent.
'''
id: int
contents: str
published_date: datetime
author: WatchUser
channel: WatchChannel
guild: WatchGuild