add bot's vote model

This commit is contained in:
Victor Kotlin 2021-09-19 11:45:26 +03:00
parent 2c0b1d1de8
commit d8df5ddb6e
2 changed files with 32 additions and 2 deletions

View file

@ -14,5 +14,6 @@ class Config:
events_list = {
"new_bot_comment": types.Comment,
"edit_bot_comment": types.EditedComment,
"delete_bot_comment": types.Comment
"delete_bot_comment": types.Comment,
"new_bot_bump": types.BotVote
}

View file

@ -79,4 +79,33 @@ class EditedComment(Comment):
name = self.__class__.__name__
return (
f'<{name} user_id={self.user_id} comment={self.comment.new}>'
)
)
class BotVote:
"""Model that represents information about bot's vote.
Attributes
-----------
raw_data : :class:`dict`
Raw data from the Boticord API.
user_id : :class:`int`
ID of user, who voted.
at : :class:`datetime.datetime`
Voting date.
"""
__slots__ = "raw_data", "user_id", "at"
raw_data: dict
user_id: int
at: datetime
def __init__(self, raw_data):
self.raw_data = raw_data["data"]
self.user_id = int(self.raw_data["user"])
self.at = datetime.fromtimestamp(self.raw_data["at"] / 1000)
def __repr__(self) -> str:
name = self.__class__.__name__
return f'<{name} user_id={self.user_id}'