diff --git a/base-config.yaml b/base-config.yaml index 269d87e..c8057a8 100644 --- a/base-config.yaml +++ b/base-config.yaml @@ -6,6 +6,16 @@ rooms: # (optional) notification_room: -# you can use {user} to reference the joining userID in this message +# if using notification_room above, format the message you'd like to send to it +# you may use the {user} variable for the full matrix ID of the user, and {room} +# for the room name in your message +# html formatting is supported +notification_message: | + User {user} has joined {room}. + +# you can use {user} to reference the joining user in this message using a +# matrix.to link (rendered as a "pill" in element clients) +# html formatting is supported message: | Welcome {user}! Please be sure to read the topic for helpful links and information. + Use Google for all other queries ;) diff --git a/maubot.yaml b/maubot.yaml index ed70711..c02cc13 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: org.jobmachine.welcome -version: 0.0.3 +version: 0.0.4 modules: - welcome main_class: Greeter diff --git a/welcome.py b/welcome.py index e703df4..c83ec95 100644 --- a/welcome.py +++ b/welcome.py @@ -15,6 +15,7 @@ class Config(BaseProxyConfig): helper.copy("rooms") helper.copy("message") helper.copy("notification_room") + helper.copy("notification_message") class Greeter(Plugin): @@ -35,8 +36,11 @@ class Greeter(Plugin): 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") + roomnamestate = await self.client.get_state_event(evt.room_id, 'm.room.name') + roomname = roomnamestate['name'] + notification_message = self.config['notification_message'].format(user=evt.sender, + room=roomname) + await self.client.send_notice(self.config["notification_room"], html=notification_message)