Skip to content

Commit

Permalink
Update Api v0.1.7 (UsergeTeam#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishna-Singhal authored May 27, 2021
1 parent 424c47c commit 0ca3dd9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions userge/plugins/admin/antispam.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -108,29 +107,29 @@ 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(
r"\\**#Userge_Antispam**//"
"\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}")
)
Expand Down

0 comments on commit 0ca3dd9

Please sign in to comment.