From 96311723341f7501ab0c11da88f60cf56425275b Mon Sep 17 00:00:00 2001 From: William Kray Date: Sat, 19 Oct 2024 16:48:37 -0700 Subject: [PATCH] add configurable welcome sleep timer --- base-config.yaml | 3 +++ community/bot.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/base-config.yaml b/base-config.yaml index df3b640..59bc87d 100644 --- a/base-config.yaml +++ b/base-config.yaml @@ -64,6 +64,9 @@ greeting_rooms: '!someotherroom:server.tld': generic '!myencryptedroomid:server.tld': encrypted +# how long to wait (in seconds) before sending a greeting to a new +welcome_sleep: 0 + # add a room ID here to send a message to when someone joins the above rooms # (optional) notification_room: diff --git a/community/bot.py b/community/bot.py index 2fac6ad..fc1e8a0 100644 --- a/community/bot.py +++ b/community/bot.py @@ -24,6 +24,7 @@ from .db import upgrade_table class Config(BaseProxyConfig): def do_update(self, helper: ConfigUpdateHelper) -> None: helper.copy("sleep") + helper.copy("welcome_sleep") helper.copy("admins") helper.copy("moderators") helper.copy("parent_room") @@ -305,6 +306,7 @@ class CommunityBot(Plugin): pill = '{nick}'.format(mxid=evt.sender, nick=nick) if greeting_name != "none": greeting = greeting_map[greeting_name].format(user=pill) + time.sleep(self.config['welcome_sleep']) await self.client.send_notice(evt.room_id, html=greeting) else: pass