enable user mention in custom message!

This commit is contained in:
William Kray 2023-06-08 05:04:07 -07:00
parent 06843a1bd7
commit 4f00f9017f
3 changed files with 7 additions and 3 deletions

View File

@ -6,5 +6,6 @@ rooms:
# (optional)
notification_room:
# you can use {user} to reference the joining userID in this message
message: |
Welcome! Please be sure to read the topic for helpful links and information.
Welcome {user}! Please be sure to read the topic for helpful links and information.

View File

@ -1,6 +1,6 @@
maubot: 0.1.0
id: org.jobmachine.welcome
version: 0.0.2
version: 0.0.3
modules:
- welcome
main_class: Greeter

View File

@ -30,7 +30,10 @@ class Greeter(Plugin):
if evt.source & SyncStream.STATE:
return
else:
await self.client.send_notice(evt.room_id, html=self.config["message"])
nick = self.client.parse_user_id(evt.sender)[0]
pill = '<a href="https://matrix.to/#/{mxid}">{nick}</a>'.format(mxid=evt.sender, nick=nick)
msg = self.config["message"].format(user=pill)
await self.client.send_notice(evt.room_id, html=msg)
if self.config["notification_room"]:
await self.client.send_markdown(self.config["notification_room"], f"User {evt.sender} joined \
{evt.room_id} and I want everyone in this @room to know")