From 925d85ed7dbc7f55da8dc6fbfbca0738d79404c1 Mon Sep 17 00:00:00 2001 From: blank X Date: Tue, 3 Nov 2020 20:14:59 +0700 Subject: [PATCH] Not raise an exception when message.reply_to_message.from_user is None --- sukuinote/plugins/log_reports.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/sukuinote/plugins/log_reports.py b/sukuinote/plugins/log_reports.py index c2569f2..e3e7546 100644 --- a/sukuinote/plugins/log_reports.py +++ b/sukuinote/plugins/log_reports.py @@ -48,17 +48,21 @@ async def log_reports(client, message): reply = message.reply_to_message if not getattr(reply, 'empty', True): text += '\n- Reportee: ' - user_text = message.reply_to_message.from_user.first_name - if message.reply_to_message.from_user.last_name: - user_text += f' {message.reply_to_message.from_user.last_name}' - user_text = '[DELETED]' if message.from_user.is_deleted else html.escape(user_text or 'Empty???') - if message.reply_to_message.from_user.is_verified: - user_text += ' [VERIFIED]' - if message.reply_to_message.from_user.is_support: - user_text += ' [SUPPORT]' - if message.reply_to_message.from_user.is_scam: - user_text += ' [SCAM]' - text += f'{user_text} [{message.reply_to_message.from_user.id}]\n- Reported Message' + if message.reply_to_message.from_user: + user_text = message.reply_to_message.from_user.first_name + if message.reply_to_message.from_user.last_name: + user_text += f' {message.reply_to_message.from_user.last_name}' + user_text = '[DELETED]' if message.from_user.is_deleted else html.escape(user_text or 'Empty???') + if message.reply_to_message.from_user.is_verified: + user_text += ' [VERIFIED]' + if message.reply_to_message.from_user.is_support: + user_text += ' [SUPPORT]' + if message.reply_to_message.from_user.is_scam: + user_text += ' [SCAM]' + user_text += f' [{message.reply_to_message.from_user.id}]' + else: + user_text = 'None???' + text += f'{user_text}\n- Reported Message' mtext = message.reply_to_message.text or message.reply_to_message.caption or '' if mtext.strip(): text += ':'