support room specifiy factoids
This commit is contained in:
parent
7199f23324
commit
a97e28de25
1 changed files with 6 additions and 2 deletions
|
@ -152,6 +152,11 @@ class Ubottu(Plugin):
|
||||||
data = await resp.json()
|
data = await resp.json()
|
||||||
value = data['value']
|
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 = {}
|
||||||
content['m.mentions'] = {}
|
content['m.mentions'] = {}
|
||||||
moderators = []
|
moderators = []
|
||||||
|
@ -173,7 +178,6 @@ class Ubottu(Plugin):
|
||||||
for user_id in user_ids:
|
for user_id in user_ids:
|
||||||
formatted_value = formatted_value.replace(user_id, '<a href="https://matrix.to/#/' + user_id + '">' + user_id + '</a>')
|
formatted_value = formatted_value.replace(user_id, '<a href="https://matrix.to/#/' + user_id + '">' + user_id + '</a>')
|
||||||
|
|
||||||
|
|
||||||
#find room moderators and add to mentions if needed
|
#find room moderators and add to mentions if needed
|
||||||
if '{moderators}' in value:
|
if '{moderators}' in value:
|
||||||
moderators = await self.get_room_mods_and_admins(evt)
|
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['formatted_body'] = mautrix.util.markdown.render(formatted_value, allow_html=True)
|
||||||
content['msgtype'] = "m.text"
|
content['msgtype'] = "m.text"
|
||||||
content['format'] = 'org.matrix.custom.html'
|
content['format'] = 'org.matrix.custom.html'
|
||||||
content['body'] = mautrix.util.markdown.render(value, allow_html=True)
|
content['body'] = value
|
||||||
if to_user:
|
if to_user:
|
||||||
content['body'] = to_user + ': ' + content['body']
|
content['body'] = to_user + ': ' + content['body']
|
||||||
content['formatted_body'] = to_user + content['formatted_body']
|
content['formatted_body'] = to_user + content['formatted_body']
|
||||||
|
|
Loading…
Reference in a new issue