Skip to content
Snippets Groups Projects
Commit c4ada971 authored by psy's avatar psy
Browse files

use format() instead of f-strings, because only newer python versions support...

use format() instead of f-strings, because only newer python versions support backslash in f-strings
parent bc7ade96
No related branches found
No related tags found
No related merge requests found
......@@ -71,10 +71,15 @@ async def on_dm(room, message):
match = botlib.MessageMatch(room, message, bot, '!')
if match.is_not_from_this_bot() and match.is_from_allowed_user() and room.name is None:
print(f"DM from {message.sender}:\n> {message.body.replace('\n', '\n> ')}")
report = f"DM from [{message.sender}](https://matrix.to/#/{message.sender}):\n" \
f"> {message.body[:config.report_maxlength].replace('\n', '\n > ')}"
print("DM from {sender}:\n> {body}".format(
sender=message.sender,
body=message.body.replace('\n', '\n> ')
))
report = "DM from [{sender}](https://matrix.to/#/{sender}):\n> {body}".format(
sender=message.sender,
body=message.body[:config.report_maxlength].replace('\n', '\n > ')
)
try:
await send_to_mgmt_room(message.sender, report)
......@@ -103,11 +108,19 @@ async def on_channel_message(room, message):
(message.formatted_body is not None and config.user_formatted in message.formatted_body)
)
):
print(f"Mention in {room.name} ({room.room_id}) by {message.sender}:\n> {message.body.replace('\n', '\n> ')}")
report = f"Mention in [{room.name}](https://matrix.to/#/{room.room_id}) by " \
f"[{message.sender}](https://matrix.to/#/{message.sender}):\n" \
f"> {message.body[:config.report_maxlength].replace('\n', '\n > ')}"
print("Mention in {room_name} ({room_id}) by {sender}:\n> {body}".format(
room_name=room.name,
room_id=room.room_id,
sender=message.sender,
body=message.body.replace('\n', '\n> ')
))
report = "Mention in [{room_name}](https://matrix.to/#/{room_id}) by [{sender}](https://matrix.to/#/{sender}):\n> {body}".format(
room_name=room.name,
room_id=room.room_id,
sender=message.sender,
body=message.body[:config.report_maxlength].replace('\n', '\n > ')
)
try:
await send_to_mgmt_room(message.sender, report)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment