Add option to send welcome message upon acceptance
This commit is contained in:
parent
912169657a
commit
337ab947ca
|
@ -52,6 +52,13 @@ vetting:
|
||||||
# The bot must be in these rooms and have the invite permission
|
# The bot must be in these rooms and have the invite permission
|
||||||
additional_rooms: []
|
additional_rooms: []
|
||||||
|
|
||||||
|
# Messages to send to the vetting room (optional)
|
||||||
|
# You can use the following variables:
|
||||||
|
# {mention} = https://matrix.to/#/@user:exmaple.com
|
||||||
|
message_on:
|
||||||
|
# Message to send once the invite has been confirmed
|
||||||
|
invited: "{mention}, you're in! 😎"
|
||||||
|
|
||||||
# Logging setup
|
# Logging setup
|
||||||
logging:
|
logging:
|
||||||
# Logging level
|
# Logging level
|
||||||
|
|
|
@ -205,7 +205,7 @@ class Callbacks:
|
||||||
if event.key == "confirm":
|
if event.key == "confirm":
|
||||||
# Check which user the reaction is for (if any)
|
# Check which user the reaction is for (if any)
|
||||||
self.store.cursor.execute(
|
self.store.cursor.execute(
|
||||||
"SELECT mxid FROM vetting WHERE decision_event_id = ?",
|
"SELECT mxid, room_id FROM vetting WHERE decision_event_id = ?",
|
||||||
(event.reacts_to,),
|
(event.reacts_to,),
|
||||||
)
|
)
|
||||||
row = self.store.cursor.fetchone()
|
row = self.store.cursor.fetchone()
|
||||||
|
@ -213,6 +213,7 @@ class Callbacks:
|
||||||
return
|
return
|
||||||
|
|
||||||
user_id = row[0]
|
user_id = row[0]
|
||||||
|
user_room_id = row[1]
|
||||||
|
|
||||||
# Invite user to main space
|
# Invite user to main space
|
||||||
logger.info("Inviting new user (%s) to the main space.", user_id)
|
logger.info("Inviting new user (%s) to the main space.", user_id)
|
||||||
|
@ -242,6 +243,18 @@ class Callbacks:
|
||||||
else:
|
else:
|
||||||
logger.info("Invited %s to %s", user_id, room_id)
|
logger.info("Invited %s to %s", user_id, room_id)
|
||||||
|
|
||||||
|
# Send message to vetting room notifying of the invite
|
||||||
|
if self.config.message_on_invited is not None:
|
||||||
|
invited_message = self.config.message_on_invited.format(
|
||||||
|
mention=f"https://matrix.to/#/{user_id}"
|
||||||
|
)
|
||||||
|
await send_text_to_room(
|
||||||
|
self.client,
|
||||||
|
user_room_id,
|
||||||
|
invited_message,
|
||||||
|
notice=False,
|
||||||
|
)
|
||||||
|
|
||||||
async def unknown(self, room: MatrixRoom, event: UnknownEvent) -> None:
|
async def unknown(self, room: MatrixRoom, event: UnknownEvent) -> None:
|
||||||
"""Callback for when an event with a type that is unknown to matrix-nio is received.
|
"""Callback for when an event with a type that is unknown to matrix-nio is received.
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,10 @@ class Config:
|
||||||
self._get_cfg(["vetting", "additional_rooms"], required=False, default=[])
|
self._get_cfg(["vetting", "additional_rooms"], required=False, default=[])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.message_on_invited: str = self._get_cfg(
|
||||||
|
["message_on", "invited"], required=False, default=None
|
||||||
|
)
|
||||||
|
|
||||||
def _get_cfg(
|
def _get_cfg(
|
||||||
self,
|
self,
|
||||||
path: List[str],
|
path: List[str],
|
||||||
|
|
Loading…
Reference in New Issue