mirror of
https://github.com/williamkray/maubot-welcome.git
synced 2024-10-01 02:35:44 -04:00
make notification message customizable, and a little friendlier to read
This commit is contained in:
parent
4f00f9017f
commit
db10517bf5
@ -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 <code>{user}</code> has joined <code>{room}</code>.
|
||||
|
||||
# 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 <a href="https://google.com">Google</a> for all other queries ;)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user