mirror of
https://github.com/boticord/boticordpy.git
synced 2024-11-11 19:07:29 +03:00
add bot's vote model
This commit is contained in:
parent
2c0b1d1de8
commit
d8df5ddb6e
2 changed files with 32 additions and 2 deletions
|
@ -14,5 +14,6 @@ class Config:
|
||||||
events_list = {
|
events_list = {
|
||||||
"new_bot_comment": types.Comment,
|
"new_bot_comment": types.Comment,
|
||||||
"edit_bot_comment": types.EditedComment,
|
"edit_bot_comment": types.EditedComment,
|
||||||
"delete_bot_comment": types.Comment
|
"delete_bot_comment": types.Comment,
|
||||||
|
"new_bot_bump": types.BotVote
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,4 +79,33 @@ class EditedComment(Comment):
|
||||||
name = self.__class__.__name__
|
name = self.__class__.__name__
|
||||||
return (
|
return (
|
||||||
f'<{name} user_id={self.user_id} comment={self.comment.new}>'
|
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}'
|
||||||
|
|
Loading…
Reference in a new issue