From 4833c7c9d28d05621761c9f197cd091261df0a71 Mon Sep 17 00:00:00 2001 From: blank X Date: Tue, 19 Jan 2021 10:43:50 +0700 Subject: [PATCH] Make eng: optional --- sukuinote/plugins/einfo.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sukuinote/plugins/einfo.py b/sukuinote/plugins/einfo.py index ca74d03..1c74c42 100644 --- a/sukuinote/plugins/einfo.py +++ b/sukuinote/plugins/einfo.py @@ -134,7 +134,7 @@ async def get_deai(client, entity): ntext.pop(0) reason = '\n'.join(ntext).strip() text += html.escape(reason) or 'None' - match = re.match(r'(?:AIdetection:)?((?:0x\d{2} )+)risk:(\S+) mod:X([0-8]) eng:(\S+)(?: cmt:(.+))?', reason) + match = re.match(r'(?:AIdetection:)?((?:0x\d{2} )+)risk:(\S+) mod:X([0-8])(?: eng:(\S+))?(?: cmt:(.+))?', reason) if match: text += '\n- Ban Codes:\n' for i in match.group(1).split(' '): @@ -142,8 +142,10 @@ async def get_deai(client, entity): i = DEAI_BAN_CODES.get(i.strip()[2:], i.strip()) text += f'--- {i}\n' text += f'- Risk Factor: {match.group(2).capitalize()}\n' - text += f'- Module: {DEAI_MODULE_CODES.get(match.group(3), match.group(3))}\n' - text += f'- Engine: {match.group(4).capitalize()}' + text += f'- Module: {DEAI_MODULE_CODES.get(match.group(3), match.group(3))}' + engine = (match.group(4) or '').strip() + if engine: + text += f'\n- Engine: {engine.capitalize()}' comment = (match.group(5) or '').strip() if comment: text += f'\n- Comment: {html.escape(comment)}'