diff --git a/base-config.yaml b/base-config.yaml index c0a1132..a740299 100644 --- a/base-config.yaml +++ b/base-config.yaml @@ -138,4 +138,11 @@ verification_phrases: - Party on, dudes. # number of attempts a user has to enter the correct verification phrase -verification_attempts: 3 \ No newline at end of file +verification_attempts: 3 + +# message to send to users when they need to verify they are human +# use {room} for the room name and {phrase} for the verification phrase +verification_message: | + Thank you for joining {room}. As an anti-spam measure, you must demonstrate that you are a real person before you can send messages in its rooms. + + Please send a message to this chat with the phrase: "{phrase}" \ No newline at end of file diff --git a/community/bot.py b/community/bot.py index 97c6ac0..097330b 100644 --- a/community/bot.py +++ b/community/bot.py @@ -76,6 +76,7 @@ class Config(BaseProxyConfig): helper.copy("check_if_human") helper.copy("verification_phrases") helper.copy("verification_attempts") + helper.copy("verification_message") class CommunityBot(Plugin): @@ -807,6 +808,13 @@ class CommunityBot(Plugin): if evt.source & SyncStream.STATE: return else: + # we only care about join events in rooms in the space + # this avoids trying to verify users in other rooms the bot might be in, + # such as public banlist policy rooms + space_rooms = await self.get_space_roomlist() + if evt.room_id not in space_rooms: + return + on_banlist = await self.check_if_banned(evt.sender) if on_banlist: await self.ban_this_user(evt.sender) @@ -902,7 +910,7 @@ class CommunityBot(Plugin): initial_state=[ { "type": str(EventType.ROOM_NAME), - "content": {"name": f"{roomname} join verification check"} + "content": {"name": f"[{roomname}] join verification"} } ] ) @@ -926,11 +934,12 @@ class CommunityBot(Plugin): } # Send greeting - greeting = f"""Thank you for joining {roomname}. As an anti-spam measure, you must demonstrate that you are a real person before you can send messages in its rooms. - -Please send a message to this chat with the phrase: "{verification_phrase}" """ - await self.client.send_notice(dm_room, greeting) - self.log.info(f"Started verification process for {evt.sender} in room {room_id}") + greeting = self.config["verification_message"].format( + room=roomname, + phrase=verification_phrase + ) + await self.client.send_notice(dm_room, html=greeting) + self.log.info(f"Started verification process for {evt.sender} in room {room_id} for room {roomname}") except Exception as e: self.log.error(f"Failed to start verification process: {e}") diff --git a/maubot.yaml b/maubot.yaml index a99fc00..06bc31d 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: org.jobmachine.communitybot -version: 0.2.3 +version: 0.2.4 license: MIT modules: - community