From 0ca3dd915a9971231317a96fbe75c8da172b0b4f Mon Sep 17 00:00:00 2001 From: Krishna-singhal <65902764+Krishna-Singhal@users.noreply.github.com> Date: Thu, 27 May 2021 15:29:39 +0530 Subject: [PATCH] Update Api v0.1.7 (#343) --- userge/plugins/admin/antispam.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/userge/plugins/admin/antispam.py b/userge/plugins/admin/antispam.py index eb433432c..ad2137c39 100644 --- a/userge/plugins/admin/antispam.py +++ b/userge/plugins/admin/antispam.py @@ -16,7 +16,6 @@ import spamwatch from spamwatch.types import Ban from UsergeAntiSpamApi import Client -from UsergeAntiSpamApi.errors import InvalidApiToken from userge import userge, Message, Config, get_collection, filters, pool @@ -108,14 +107,14 @@ async def gban_at_entry(message: Message): continue if Config.USERGE_ANTISPAM_API: try: - response = await _get_userge_antispam_data(user_id) - except InvalidApiToken: + ban = await _get_userge_antispam_data(user_id) + except Exception as err: if not warned: - LOG.error("Your Userge AntiSpam Api key is Invalid!") - await CHANNEL.log("Your Userge AntiSpam Api key is Invalid!") + LOG.error(err) + await CHANNEL.log(err) warned = True else: - if response["success"]: + if ban: await asyncio.gather( message.client.kick_chat_member(chat_id, user_id), message.reply( @@ -123,14 +122,14 @@ async def gban_at_entry(message: Message): "\n\nGlobally Banned User Detected in this Chat.\n\n" "**$SENTRY Userge AntiSpam API Ban**\n" f"**User:** [{first_name}](tg://user?id={user_id})\n" - f"**ID:** `{user_id}`\n**Reason:** `{response['reason']}`\n\n" + f"**ID:** `{user_id}`\n**Reason:** `{ban.reason}`\n\n" "**Quick Action:** Banned", del_in=10), CHANNEL.log( r"\\**#Antispam_Log**//" "\n\n**GBanned User $SPOTTED**\n" "**$SENRTY #USERGE_ANTISPAM_API BAN**" f"\n**User:** [{first_name}](tg://user?id={user_id})\n" - f"**ID:** `{user_id}`\n**Reason:** `{response['reason']}`\n" + f"**ID:** `{user_id}`\n**Reason:** `{ban.reason}`\n" f"**Quick Action:** Banned in {message.chat.title}\n\n" f"$AUTOBAN #id{user_id}") )