Skip to content

Commit

Permalink
typo in whitelist (UsergeTeam#282)
Browse files Browse the repository at this point in the history
* typo

* trying to fix (Merge with statements)
  • Loading branch information
Krishna-Singhal authored Mar 18, 2021
1 parent dc2bcd4 commit 75237d5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions userge/plugins/admin/gban.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async def list_gbanned(message: Message):
@userge.on_cmd("whitelist", about={
'header': "Whitelist a User",
'description': "Use whitelist to add users to bypass API Bans",
'useage': "{tr}whitelist [userid | reply to user]",
'usage': "{tr}whitelist [userid | reply to user]",
'examples': "{tr}whitelist 5231147869"},
allow_channels=False, allow_bots=False)
async def whitelist(message: Message):
Expand Down Expand Up @@ -291,9 +291,7 @@ async def gban_at_entry(message: Message):
{"$set": {'chat_ids': chat_ids}}, upsert=True)
)
elif Config.ANTISPAM_SENTRY:
async with aiohttp.ClientSession() as ses:
async with ses.get(f'https://api.cas.chat/check?user_id={user_id}') as resp:
res = json.loads(await resp.text())
res = await getData(f'https://api.cas.chat/check?user_id={user_id}')
if res['ok']:
reason = ' | '.join(
res['result']['messages']) if 'result' in res else None
Expand All @@ -315,11 +313,9 @@ async def gban_at_entry(message: Message):
f" Banned in {message.chat.title}\n\n$AUTOBAN #id{user_id}")
)
continue
async with aiohttp.ClientSession() as ses:
async with ses.get(
"https://api.intellivoid.net/spamprotection/v1/lookup?query=" + str(user_id)
) as resp:
iv = json.loads(await resp.text())
iv = await getData(
"https://api.intellivoid.net/spamprotection/v1/lookup?query=" + str(user_id)
)
if iv['success'] and iv['results']['attributes']['is_blacklisted'] is True:
reason = iv['results']['attributes']['blacklist_reason']
await asyncio.gather(
Expand Down Expand Up @@ -363,6 +359,12 @@ async def gban_at_entry(message: Message):
message.continue_propagation()


async def getData(link: str):
async with aiohttp.ClientSession() as ses:
async with ses.get(link) as resp:
return json.loads(await resp.text())


@pool.run_in_thread
def _get_spamwatch_data(user_id: int) -> Union[Ban, bool]:
return spamwatch.Client(Config.SPAM_WATCH_API).get_ban(user_id)

0 comments on commit 75237d5

Please sign in to comment.