From a97e28de2583fdca86e3f818a1f98ba354e6d5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20B=C3=BCchner?= Date: Sat, 8 Jun 2024 19:18:16 +0200 Subject: [PATCH] support room specifiy factoids --- ubottu/bot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ubottu/bot.py b/ubottu/bot.py index 8b050f5..6bb6027 100644 --- a/ubottu/bot.py +++ b/ubottu/bot.py @@ -152,6 +152,11 @@ class Ubottu(Plugin): data = await resp.json() value = data['value'] + # if factoid is room specific check and only reply in this room + room = data['room'] + if room is not None and room != evt.room_id: + return False + content = {} content['m.mentions'] = {} moderators = [] @@ -173,7 +178,6 @@ class Ubottu(Plugin): for user_id in user_ids: formatted_value = formatted_value.replace(user_id, '' + user_id + '') - #find room moderators and add to mentions if needed if '{moderators}' in value: moderators = await self.get_room_mods_and_admins(evt) @@ -196,7 +200,7 @@ class Ubottu(Plugin): content['formatted_body'] = mautrix.util.markdown.render(formatted_value, allow_html=True) content['msgtype'] = "m.text" content['format'] = 'org.matrix.custom.html' - content['body'] = mautrix.util.markdown.render(value, allow_html=True) + content['body'] = value if to_user: content['body'] = to_user + ': ' + content['body'] content['formatted_body'] = to_user + content['formatted_body']