Anonymous admin support for log_forwards and log_reports

This commit is contained in:
blank X 2020-12-24 16:40:29 +07:00
parent bc911d5baa
commit 1dbde24525
2 changed files with 35 additions and 26 deletions

View File

@ -12,7 +12,7 @@ lock = asyncio.Lock()
async def log_forwards(client, message):
if not config['config'].get('log_forwards'):
return
if not message.from_user or message.from_user.id in app_user_ids:
if getattr(message.from_user, 'id', None) in app_user_ids:
return
for i in app_user_ids:
if message.forward_from:
@ -41,7 +41,9 @@ async def log_forwards(client, message):
chat_text += '<code>[SUPPORT]</code> '
if message.chat.is_scam:
chat_text += '<code>[SCAM]</code> '
text += f'[<code>{message.chat.id}</code>]\n- <b>Forwarder:</b> '
text += f'[<code>{message.chat.id}</code>]'
if message.chat.type != 'channel':
if message.from_user:
user_text = message.from_user.first_name
if message.from_user.last_name:
user_text += f' {message.from_user.last_name}'
@ -52,8 +54,11 @@ async def log_forwards(client, message):
user_text += ' <code>[SUPPORT]</code>'
if message.from_user.is_scam:
user_text += ' <code>[SCAM]</code>'
text += f'{user_text} [<code>{message.from_user.id}</code>]\n'
text += f'- <b><a href="{message.link}">Message'
user_text += f' [<code>{message.from_user.id}</code>]'
else:
user_text = 'Anonymous'
text += f'\n- <b>Forwarder:</b> {user_text}'
text += f'\n- <b><a href="{message.link}">Message'
mtext = (message.text or message.caption or '').strip()
if mtext:
text += ':'

View File

@ -27,6 +27,7 @@ async def log_reports(client, message):
if message.chat.is_scam:
chat_text += '<code>[SCAM]</code> '
text += f'[<code>{message.chat.id}</code>]\n- <b>Reporter:</b> '
if message.from_user:
user_text = message.from_user.first_name
if message.from_user.last_name:
user_text += f' {message.from_user.last_name}'
@ -37,7 +38,10 @@ async def log_reports(client, message):
user_text += ' <code>[SUPPORT]</code>'
if message.from_user.is_scam:
user_text += ' <code>[SCAM]</code>'
text += f'{user_text} [<code>{message.from_user.id}</code>]\n'
user_text += f' [<code>{message.from_user.id}</code>]'
else:
user_text = 'Anonymous'
text += f'{user_text}\n'
start, end = message.matches[0].span()
text += f'- <b><a href="{message.link}">Report Message'
mtext = (message.text or message.caption or '').strip()
@ -62,7 +66,7 @@ async def log_reports(client, message):
user_text += ' <code>[SCAM]</code>'
user_text += f' [<code>{reply.from_user.id}</code>]'
else:
user_text = 'None???'
user_text = 'Anonymous'
text += f'{user_text}\n- <b><a href="{reply.link}">Reported Message'
mtext = reply.text or reply.caption or ''
if mtext.strip():