Not raise an exception when message.reply_to_message.from_user is None

This commit is contained in:
blank X 2020-11-03 20:14:59 +07:00
parent 657a857e13
commit 925d85ed7d
1 changed files with 15 additions and 11 deletions

View File

@ -48,6 +48,7 @@ async def log_reports(client, message):
reply = message.reply_to_message reply = message.reply_to_message
if not getattr(reply, 'empty', True): if not getattr(reply, 'empty', True):
text += '\n- <b>Reportee:</b> ' text += '\n- <b>Reportee:</b> '
if message.reply_to_message.from_user:
user_text = message.reply_to_message.from_user.first_name user_text = message.reply_to_message.from_user.first_name
if message.reply_to_message.from_user.last_name: if message.reply_to_message.from_user.last_name:
user_text += f' {message.reply_to_message.from_user.last_name}' user_text += f' {message.reply_to_message.from_user.last_name}'
@ -58,7 +59,10 @@ async def log_reports(client, message):
user_text += ' <code>[SUPPORT]</code>' user_text += ' <code>[SUPPORT]</code>'
if message.reply_to_message.from_user.is_scam: if message.reply_to_message.from_user.is_scam:
user_text += ' <code>[SCAM]</code>' user_text += ' <code>[SCAM]</code>'
text += f'{user_text} [<code>{message.reply_to_message.from_user.id}</code>]\n- <b><a href="{message.reply_to_message.link}">Reported Message' user_text += f' [<code>{message.reply_to_message.from_user.id}</code>]'
else:
user_text = 'None???'
text += f'{user_text}\n- <b><a href="{message.reply_to_message.link}">Reported Message'
mtext = message.reply_to_message.text or message.reply_to_message.caption or '' mtext = message.reply_to_message.text or message.reply_to_message.caption or ''
if mtext.strip(): if mtext.strip():
text += ':' text += ':'