(Try to) force ltr on log_*

This commit is contained in:
blank X 2021-04-04 11:09:00 +07:00
parent 00adc73dd4
commit 50acc5843c
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
3 changed files with 20 additions and 16 deletions

View File

@ -6,6 +6,7 @@ from .. import config, log_errors, app_user_ids, log_ring
logged = defaultdict(set) logged = defaultdict(set)
lock = asyncio.Lock() lock = asyncio.Lock()
force_ltr = '\u200E'
@Client.on_message(~filters.chat(config['config']['log_chat']) & filters.incoming & filters.forwarded & (filters.group | filters.channel)) @Client.on_message(~filters.chat(config['config']['log_chat']) & filters.incoming & filters.forwarded & (filters.group | filters.channel))
@log_errors @log_errors
@ -33,7 +34,7 @@ async def log_forwards(client, message):
chat_text = html.escape(message.chat.title) chat_text = html.escape(message.chat.title)
if message.chat.username: if message.chat.username:
chat_text = f'<a href="https://t.me/{message.chat.username}">{chat_text}</a>' chat_text = f'<a href="https://t.me/{message.chat.username}">{chat_text}</a>'
text = f'<b>Forwarded Event</b>\n- <b>Chat:</b> {chat_text} ' text = f'<b>Forwarded Event</b>\n{force_ltr}- <b>Chat:</b> {chat_text} '
if message.chat.is_verified: if message.chat.is_verified:
chat_text += '<code>[VERIFIED]</code> ' chat_text += '<code>[VERIFIED]</code> '
if message.chat.is_support: if message.chat.is_support:
@ -72,15 +73,15 @@ async def log_forwards(client, message):
user_text += ' <code>[FAKE]</code>' user_text += ' <code>[FAKE]</code>'
else: else:
user_text = 'Anonymous' user_text = 'Anonymous'
text += f'\n- <b>Forwarder:</b> {user_text}' text += f'\n{force_ltr}- <b>Forwarder:</b> {user_text}'
text += f'\n- <b><a href="{message.link}">Message' text += f'\n- <b><a href="{message.link}">Message'
mtext = (message.text or message.caption or '').strip() mtext = (message.text or message.caption or '').strip()
if mtext: if mtext:
text += ':' text += ':'
text += '</a></b>' text += '</a></b>'
if mtext: if mtext:
text += f' {html.escape(mtext.strip()[:2000])}' text += f'{force_ltr} {html.escape(mtext.strip()[:2000])}'
text += '\n- <b>Forwardee:</b> ' text += '\n{force_ltr}- <b>Forwardee:</b> '
user_text = forwardee.first_name user_text = forwardee.first_name
if forwardee.last_name: if forwardee.last_name:
user_text += f' {forwardee.last_name}' user_text += f' {forwardee.last_name}'

View File

@ -6,6 +6,7 @@ from .. import config, log_errors, log_ring
reported = defaultdict(set) reported = defaultdict(set)
lock = asyncio.Lock() lock = asyncio.Lock()
force_ltr = '\u200E'
@Client.on_message(~filters.chat(config['config']['log_chat']) & filters.regex(r'(?:^|\s+)@admins?(?:$|\W+)|^[/!](?:report|admins?)(?:$|\W+)') & filters.group) @Client.on_message(~filters.chat(config['config']['log_chat']) & filters.regex(r'(?:^|\s+)@admins?(?:$|\W+)|^[/!](?:report|admins?)(?:$|\W+)') & filters.group)
@log_errors @log_errors
@ -18,7 +19,7 @@ async def log_reports(client, message):
chat_text = html.escape(message.chat.title) chat_text = html.escape(message.chat.title)
if message.chat.username: if message.chat.username:
chat_text = f'<a href="https://t.me/{message.chat.username}">{chat_text}</a>' chat_text = f'<a href="https://t.me/{message.chat.username}">{chat_text}</a>'
text = f'<b>Report Event</b>\n- <b>Chat:</b> {chat_text} ' text = f'<b>Report Event</b>\n{force_ltr}- <b>Chat:</b> {chat_text} '
if message.chat.is_verified: if message.chat.is_verified:
chat_text += '<code>[VERIFIED]</code> ' chat_text += '<code>[VERIFIED]</code> '
if message.chat.is_support: if message.chat.is_support:
@ -27,7 +28,7 @@ async def log_reports(client, message):
chat_text += '<code>[SCAM]</code> ' chat_text += '<code>[SCAM]</code> '
if getattr(message.chat, 'is_fake', None): if getattr(message.chat, 'is_fake', None):
chat_text += '<code>[FAKE]</code> ' chat_text += '<code>[FAKE]</code> '
text += f'[<code>{message.chat.id}</code>]\n- <b>Reporter:</b> ' text += f'[<code>{message.chat.id}</code>]\n{force_ltr}- <b>Reporter:</b> '
if message.from_user: if message.from_user:
user_text = message.from_user.first_name user_text = message.from_user.first_name
if message.from_user.last_name: if message.from_user.last_name:
@ -58,16 +59,16 @@ async def log_reports(client, message):
user_text = 'Anonymous' user_text = 'Anonymous'
text += f'{user_text}\n' text += f'{user_text}\n'
start, end = message.matches[0].span() start, end = message.matches[0].span()
text += f'- <b><a href="{message.link}">Report Message' text += f'{force_ltr}- <b><a href="{message.link}">Report Message'
mtext = (message.text or message.caption or '').strip() mtext = (message.text or message.caption or '').strip()
if start or end < len(mtext): if start or end < len(mtext):
text += ':' text += ':'
text += '</a></b>' text += '</a></b>'
if start or end < len(mtext): if start or end < len(mtext):
text += f' {html.escape(mtext.strip()[:1000])}' text += f'{force_ltr} {html.escape(mtext.strip()[:1000])}'
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{force_ltr}- <b>Reportee:</b> '
if reply.from_user: if reply.from_user:
user_text = reply.from_user.first_name user_text = reply.from_user.first_name
if reply.from_user.last_name: if reply.from_user.last_name:
@ -96,10 +97,10 @@ async def log_reports(client, message):
user_text += ' <code>[FAKE]</code>' user_text += ' <code>[FAKE]</code>'
else: else:
user_text = 'Anonymous' user_text = 'Anonymous'
text += f'{user_text}\n- <b><a href="{reply.link}">Reported Message' text += f'{user_text}\n{force_ltr}- <b><a href="{reply.link}">Reported Message'
mtext = reply.text or reply.caption or '' mtext = reply.text or reply.caption or ''
if mtext.strip(): if mtext.strip():
text += ':' text += ':'
text += f'</a></b> {html.escape(mtext.strip()[:1000])}' text += f'</a></b>{force_ltr} {html.escape(mtext.strip()[:1000])}'
log_ring.append(text) log_ring.append(text)
reported[message.chat.id].add(message.message_id) reported[message.chat.id].add(message.message_id)

View File

@ -13,6 +13,8 @@ def sexy_user_name(user):
handled = defaultdict(set) handled = defaultdict(set)
lock = asyncio.Lock() lock = asyncio.Lock()
force_ltr = '\u200E'
@Client.on_raw_update() @Client.on_raw_update()
@log_errors @log_errors
async def log_user_joins(client, update, users, chats): async def log_user_joins(client, update, users, chats):
@ -39,7 +41,7 @@ async def log_user_joins(client, update, users, chats):
raise ContinuePropagation raise ContinuePropagation
if not is_join and not config['config']['log_user_adds']: if not is_join and not config['config']['log_user_adds']:
raise ContinuePropagation raise ContinuePropagation
text = f"<b>{'User Join Event' if is_join else 'User Add Event'}</b>\n- <b>Chat:</b> " text = f"<b>{'User Join Event' if is_join else 'User Add Event'}</b>\n{force_ltr}- <b>Chat:</b> "
atext = html.escape(chats[chat_id].title) atext = html.escape(chats[chat_id].title)
if getattr(chats[chat_id], 'username', None): if getattr(chats[chat_id], 'username', None):
atext = f'<a href="https://t.me/{chats[chat_id].username}">{atext}</a>' atext = f'<a href="https://t.me/{chats[chat_id].username}">{atext}</a>'
@ -51,13 +53,13 @@ async def log_user_joins(client, update, users, chats):
else: else:
adder = 'Anonymous' adder = 'Anonymous'
if is_join: if is_join:
text += f'- <b>User:</b> {adder}\n' text += f'{force_ltr}- <b>User:</b> {adder}\n'
if isinstance(action, MessageActionChatJoinedByLink): if isinstance(action, MessageActionChatJoinedByLink):
text += f'- <b>Inviter:</b> {sexy_user_name(users[action.inviter_id])}' text += f'{force_ltr}- <b>Inviter:</b> {sexy_user_name(users[action.inviter_id])}'
else: else:
text += f'- <b>Adder:</b> {adder}\n- <b>Added Users:</b>\n' text += f'{force_ltr}- <b>Adder:</b> {adder}\n{force_ltr}- <b>Added Users:</b>\n'
for user in action.users: for user in action.users:
text += f'--- {sexy_user_name(users[user])}\n' text += f'{force_ltr}--- {sexy_user_name(users[user])}\n'
log_ring.append(text) log_ring.append(text)
handled[sexy_chat_id].add(message.id) handled[sexy_chat_id].add(message.id)
return return