From d8df5ddb6e76e617259720d6f02cb37029b25e8e Mon Sep 17 00:00:00 2001 From: Victor Kotlin Date: Sun, 19 Sep 2021 11:45:26 +0300 Subject: [PATCH] add bot's vote model --- boticordpy/config.py | 3 ++- boticordpy/types.py | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/boticordpy/config.py b/boticordpy/config.py index eae7b9f..0f001dd 100644 --- a/boticordpy/config.py +++ b/boticordpy/config.py @@ -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 } diff --git a/boticordpy/types.py b/boticordpy/types.py index fd4c5e9..74f505c 100644 --- a/boticordpy/types.py +++ b/boticordpy/types.py @@ -79,4 +79,33 @@ class EditedComment(Comment): name = self.__class__.__name__ return ( f'<{name} user_id={self.user_id} comment={self.comment.new}>' - ) \ No newline at end of file + ) + + +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}'