From 2c0b1d1de82da89caa75cfff90aa48503d37ce69 Mon Sep 17 00:00:00 2001 From: grey-cat-1908 Date: Sat, 18 Sep 2021 17:53:48 +0300 Subject: [PATCH] fix comments classes --- boticordpy/config.py | 2 +- boticordpy/types.py | 2 +- boticordpy/webhook.py | 4 +++- examples/webhook.py | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/boticordpy/config.py b/boticordpy/config.py index 0ccd0b8..eae7b9f 100644 --- a/boticordpy/config.py +++ b/boticordpy/config.py @@ -14,5 +14,5 @@ class Config: events_list = { "new_bot_comment": types.Comment, "edit_bot_comment": types.EditedComment, - "delete_bot_comment": types.EditedComment + "delete_bot_comment": types.Comment } diff --git a/boticordpy/types.py b/boticordpy/types.py index f808aea..fd4c5e9 100644 --- a/boticordpy/types.py +++ b/boticordpy/types.py @@ -48,7 +48,7 @@ class Comment: self.raw_data = raw_data["data"] self.user_id = int(self.raw_data["user"]) self.comment = self.raw_data["comment"] - self.at = datetime.fromtimestamp(self.raw_data["at"]) + self.at = datetime.fromtimestamp(self.raw_data["at"] / 1000) def __repr__(self) -> str: name = self.__class__.__name__ diff --git a/boticordpy/webhook.py b/boticordpy/webhook.py index 1c27d4a..ecd7123 100644 --- a/boticordpy/webhook.py +++ b/boticordpy/webhook.py @@ -72,7 +72,9 @@ class BoticordWebhook: auth = request.headers.get("X-Hook-Key") if auth == self._webhooks["bot"]["hook_key"]: - data = (await request.json()) + + data = await request.json() + event_in_config = config.Config.events_list.get(data["type"]) if event_in_config is not None: diff --git a/examples/webhook.py b/examples/webhook.py index c25dd04..12d7b91 100644 --- a/examples/webhook.py +++ b/examples/webhook.py @@ -13,4 +13,5 @@ boticord_webhook.run(5000) async def on_boticord_comment_edit(data): print(data) + bot.run("bot-token") \ No newline at end of file