Add sibyl to extended info

This commit is contained in:
blank X 2021-11-20 20:00:38 +07:00
parent 3cd21e6065
commit 17095861ae
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 34 additions and 4 deletions

View File

@ -14,6 +14,7 @@ config:
spamwatch_api: https://t.me/SpamWatchBot spamwatch_api: https://t.me/SpamWatchBot
saucenao_api: https://saucenao.com/user.php?page=search-api saucenao_api: https://saucenao.com/user.php?page=search-api
lolicon_api: https://t.me/loliconApiBot lolicon_api: https://t.me/loliconApiBot
sibyl_api: https://t.me/SibylRobot
log_user_joins: false log_user_joins: false
log_user_adds: true log_user_adds: true
log_reports: true log_reports: true

View File

@ -50,7 +50,7 @@ DEAI_MODULE_CODES = {
"8": "Codename Gestapo" "8": "Codename Gestapo"
} }
@Client.on_message(~filters.scheduled & ~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['einfo', 'externalinfo', 'sw', 'spamwatch', 'deai', 'spb', 'spamprotection', 'cas', 'combot', 'rose'], prefixes=config['config']['prefixes'])) @Client.on_message(~filters.scheduled & ~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['einfo', 'externalinfo', 'sw', 'spamwatch', 'deai', 'spb', 'spamprotection', 'cas', 'combot', 'rose', 'sibyl'], prefixes=config['config']['prefixes']))
@log_errors @log_errors
@public_log_errors @public_log_errors
async def fedstat(client, message): async def fedstat(client, message):
@ -76,8 +76,10 @@ async def fedstat(client, message):
await message.reply_text(f'Rose Support:\n{await get_rose(client, entity)}') await message.reply_text(f'Rose Support:\n{await get_rose(client, entity)}')
elif command in ('cas', 'combot'): elif command in ('cas', 'combot'):
await message.reply_text(f'CAS:\n{await get_cas(entity)}') await message.reply_text(f'CAS:\n{await get_cas(entity)}')
elif command == 'sibyl':
await message.reply_text(f'Sibyl:\n{await get_sibyl(entity)}')
else: else:
spamwatch, deai, cas, spam_protection, rose = await asyncio.gather(get_spamwatch(entity), get_deai(client, entity), get_cas(entity), get_spam_protection(entity), get_rose(client, entity)) spamwatch, deai, cas, spam_protection, rose, sibyl = await asyncio.gather(get_spamwatch(entity), get_deai(client, entity), get_cas(entity), get_spam_protection(entity), get_rose(client, entity), get_sibyl(entity))
await message.reply_text(f'''SpamWatch: await message.reply_text(f'''SpamWatch:
{spamwatch} {spamwatch}
@ -91,7 +93,10 @@ DEAI:
{deai} {deai}
Spam Protection: Spam Protection:
{spam_protection}''') {spam_protection}
Sibyl:
{sibyl}''')
async def get_spamwatch(entity): async def get_spamwatch(entity):
async with session.get(f'https://api.spamwat.ch/banlist/{entity}', headers={'Authorization': f'Bearer {config["config"]["spamwatch_api"]}'}) as resp: async with session.get(f'https://api.spamwat.ch/banlist/{entity}', headers={'Authorization': f'Bearer {config["config"]["spamwatch_api"]}'}) as resp:
@ -200,6 +205,27 @@ async def get_spam_protection(entity):
return text return text
return f'- <b>{json["response_code"]}</b>: {json["error"]["error_code"]}: {json["error"]["type"]}: {html.escape(json["error"]["message"])}' return f'- <b>{json["response_code"]}</b>: {json["error"]["error_code"]}: {json["error"]["type"]}: {html.escape(json["error"]["message"])}'
async def get_sibyl(entity):
if not config['config'].get('sibyl_api'):
return '- <b>404:</b> Missing sibyl api key'
async with session.get(f'https://psychopass.animekaizoku.com/getInfo?token={config["config"]["sibyl_api"]}&userid={entity}') as resp:
json = await resp.json()
if json['error']:
return f'- <b>{json["error"]["code"]}:</b> {html.escape(json["error"]["message"])}'
json = json['result']
text = ''
if json['banned']:
text = f'- <b>Banned on:</b> {datetime.datetime.strptime(json["date"], "%Y-%m-%d at %H:%M:%S")}\n'
text += f'- <b>Reason:</b> {html.escape(json["reason"])}\n'
text += f'- <b>Crime Coefficient:</b> {json["crime_coefficient"]}'
if json['ban_flags']:
text += f'\n- <b>Ban Flags:</b> {html.escape(", ".join(json["ban_flags"]))}'
if json['ban_source_url']:
text += f'\n- <b>Ban Source URL:</b> {html.escape(json["ban_source_url"])}'
if json['source_group']:
text += f'\n- <b>Source Group:</b> {html.escape(json["ban_source_url"])}'
return text
@Client.on_message(~filters.scheduled & ~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.chat(['rsophiebot', 'missrose_bot']) & filters.incoming & filters.regex('^Federation ban info:\n|You aren\'t fbanned in this fed\.|^Failed to get user: unable to getChatMember: Bad Request: chat not found$|^(?:.+ )?is not banned in this fed\.$|^(?:.+ )?is currently banned in Rose Support Official, for the following reason:\n\n|^Looks like I don\'t have control over that user, or the ID isn\'t a valid one\. If you reply to one of their messages, I\'ll be able to interact with them\.$')) @Client.on_message(~filters.scheduled & ~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.chat(['rsophiebot', 'missrose_bot']) & filters.incoming & filters.regex('^Federation ban info:\n|You aren\'t fbanned in this fed\.|^Failed to get user: unable to getChatMember: Bad Request: chat not found$|^(?:.+ )?is not banned in this fed\.$|^(?:.+ )?is currently banned in Rose Support Official, for the following reason:\n\n|^Looks like I don\'t have control over that user, or the ID isn\'t a valid one\. If you reply to one of their messages, I\'ll be able to interact with them\.$'))
async def fedstat_conversation_hack(client, message): async def fedstat_conversation_hack(client, message):
reply = message.reply_to_message reply = message.reply_to_message
@ -230,4 +256,7 @@ Aliases: {prefix}combot
{prefix}spamprotection <i>&lt;user&gt;</i> - Get Spam Protection info of <i>&lt;user&gt;</i> {prefix}spamprotection <i>&lt;user&gt;</i> - Get Spam Protection info of <i>&lt;user&gt;</i>
{prefix}spamprotection <i>(as reply to message)</i> - Get Spam Protection info of replied user {prefix}spamprotection <i>(as reply to message)</i> - Get Spam Protection info of replied user
Aliases: {prefix}spb''') Aliases: {prefix}spb'
{prefix}sibyl <i>&lt;user&gt;</i> - Get Sibyl's judgement of <i>&lt;user&gt;</i>
{prefix}sibyl <i>(as reply to message)</i> - Get Sibyl's judement of the replied to user''')