more cleanup of messages, and customizability for verification message!

This commit is contained in:
William Kray
2025-04-10 09:45:35 -07:00
parent a9bf6be4a6
commit dc83711efc
3 changed files with 24 additions and 8 deletions
+7
View File
@@ -139,3 +139,10 @@ verification_phrases:
# number of attempts a user has to enter the correct verification phrase # number of attempts a user has to enter the correct verification phrase
verification_attempts: 3 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}"
+15 -6
View File
@@ -76,6 +76,7 @@ class Config(BaseProxyConfig):
helper.copy("check_if_human") helper.copy("check_if_human")
helper.copy("verification_phrases") helper.copy("verification_phrases")
helper.copy("verification_attempts") helper.copy("verification_attempts")
helper.copy("verification_message")
class CommunityBot(Plugin): class CommunityBot(Plugin):
@@ -807,6 +808,13 @@ class CommunityBot(Plugin):
if evt.source & SyncStream.STATE: if evt.source & SyncStream.STATE:
return return
else: 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) on_banlist = await self.check_if_banned(evt.sender)
if on_banlist: if on_banlist:
await self.ban_this_user(evt.sender) await self.ban_this_user(evt.sender)
@@ -902,7 +910,7 @@ class CommunityBot(Plugin):
initial_state=[ initial_state=[
{ {
"type": str(EventType.ROOM_NAME), "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 # 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. greeting = self.config["verification_message"].format(
room=roomname,
Please send a message to this chat with the phrase: "{verification_phrase}" """ 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}") 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: except Exception as e:
self.log.error(f"Failed to start verification process: {e}") self.log.error(f"Failed to start verification process: {e}")
+1 -1
View File
@@ -1,6 +1,6 @@
maubot: 0.1.0 maubot: 0.1.0
id: org.jobmachine.communitybot id: org.jobmachine.communitybot
version: 0.2.3 version: 0.2.4
license: MIT license: MIT
modules: modules:
- community - community