From aee5cdf6a5f4bd6c325b875d461d25253948d75c Mon Sep 17 00:00:00 2001 From: profitroll Date: Sat, 12 Aug 2023 22:36:26 +0200 Subject: [PATCH] Fixed user selected emoji bug --- classes/pyrouser.py | 4 ++++ plugins/handlers/user_join.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/classes/pyrouser.py b/classes/pyrouser.py index 41b4480..bb8805e 100644 --- a/classes/pyrouser.py +++ b/classes/pyrouser.py @@ -85,6 +85,10 @@ class PyroUser: logger.debug("%s's mistakes count has been set to %s", self.id, mistakes) await col_users.update_one({"_id": self._id}, {"$set": {"mistakes": mistakes}}) + async def set_selected(self, emojis: List[str] = None) -> None: + logger.debug("%s's elected emojis have been set to %s", self.id, emojis) + await col_users.update_one({"_id": self._id}, {"$set": {"selected": emojis}}) + async def update_score(self, points: int = 1) -> None: logger.debug("%s point(s) have been added to %s score", points, self.id) await col_users.update_one( diff --git a/plugins/handlers/user_join.py b/plugins/handlers/user_join.py index 4d9f3a9..7f4e400 100644 --- a/plugins/handlers/user_join.py +++ b/plugins/handlers/user_join.py @@ -69,6 +69,9 @@ async def handler_user_join(app: PyroClient, message: Message): await user.set_score(0) await user.set_mistakes(0) + if len(user.selected) > 0: + await user.set_selected([]) + await asyncio.sleep(2) verification_request = await app.send_message( chat_id=group.id, @@ -80,13 +83,13 @@ async def handler_user_join(app: PyroClient, message: Message): [ InlineKeyboardButton( app._("verify", "buttons", locale=locale), - callback_data=f"verify;{user.id}", + callback_data=f"verify:{user.id}", ) ], [ InlineKeyboardButton( app._("ban", "buttons", locale=locale), - callback_data=f"ban;{user.id}", + callback_data=f"ban:{user.id}", ) ], ],