From 17095861aee0dcd62d23e382877a9e003bd74574 Mon Sep 17 00:00:00 2001 From: blank X Date: Sat, 20 Nov 2021 20:00:38 +0700 Subject: [PATCH] Add sibyl to extended info --- example-config.yaml | 1 + sukuinote/plugins/einfo.py | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/example-config.yaml b/example-config.yaml index 648cb1c..a0b5971 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -14,6 +14,7 @@ config: spamwatch_api: https://t.me/SpamWatchBot saucenao_api: https://saucenao.com/user.php?page=search-api lolicon_api: https://t.me/loliconApiBot + sibyl_api: https://t.me/SibylRobot log_user_joins: false log_user_adds: true log_reports: true diff --git a/sukuinote/plugins/einfo.py b/sukuinote/plugins/einfo.py index 391c2fb..5c69475 100644 --- a/sukuinote/plugins/einfo.py +++ b/sukuinote/plugins/einfo.py @@ -50,7 +50,7 @@ DEAI_MODULE_CODES = { "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 @public_log_errors 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)}') elif command in ('cas', 'combot'): 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: - 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: {spamwatch} @@ -91,7 +93,10 @@ DEAI: {deai} Spam Protection: -{spam_protection}''') +{spam_protection} + +Sibyl: +{sibyl}''') 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: @@ -200,6 +205,27 @@ async def get_spam_protection(entity): return text return f'- {json["response_code"]}: {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 '- 404: 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'- {json["error"]["code"]}: {html.escape(json["error"]["message"])}' + json = json['result'] + text = '' + if json['banned']: + text = f'- Banned on: {datetime.datetime.strptime(json["date"], "%Y-%m-%d at %H:%M:%S")}\n' + text += f'- Reason: {html.escape(json["reason"])}\n' + text += f'- Crime Coefficient: {json["crime_coefficient"]}' + if json['ban_flags']: + text += f'\n- Ban Flags: {html.escape(", ".join(json["ban_flags"]))}' + if json['ban_source_url']: + text += f'\n- Ban Source URL: {html.escape(json["ban_source_url"])}' + if json['source_group']: + text += f'\n- Source Group: {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\.$')) async def fedstat_conversation_hack(client, message): reply = message.reply_to_message @@ -230,4 +256,7 @@ Aliases: {prefix}combot {prefix}spamprotection <user> - Get Spam Protection info of <user> {prefix}spamprotection (as reply to message) - Get Spam Protection info of replied user -Aliases: {prefix}spb''') +Aliases: {prefix}spb' + +{prefix}sibyl <user> - Get Sibyl's judgement of <user> +{prefix}sibyl (as reply to message) - Get Sibyl's judement of the replied to user''')