From 4e923fd55ebd5c54892813df865293e24945430e Mon Sep 17 00:00:00 2001 From: khuxkm fbexl Date: Wed, 25 Nov 2020 07:35:44 +0000 Subject: [PATCH] Add DJ topic system --- tilderadio.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tilderadio.py b/tilderadio.py index 6ffb088..5dba115 100644 --- a/tilderadio.py +++ b/tilderadio.py @@ -327,3 +327,31 @@ class Module(ModuleManager.BaseModule): event["stdout"].write( utils.datetime.format.datetime_human(utils.datetime.utcnow()) ) + + @utils.hook("received.command.setdjtopic") + @utils.kwarg("require_mode","v") + @utils.kwarg("help","set your personal DJ topic") + @utils.spec("!string") + def setdjtopic(self, event): + if event["target"].name!="#tilderadio": + event["stderr"].write("setdjtopic command can only be used in #tilderadio") + return + topic = event["spec"][0] + event["user"].set_setting("tilderadio-djtopic",topic) + + @utils.hook("received.command.djtopic") + @utils.kwarg("help","get the DJ topic for the active DJ or for any DJ") + @utils.spec("?user") + def setdjtopic(self, event): + dj = event["spec"][0] + if dj is None: + if event["server"].has_user_id(self.dj): + dj = event["server"].get_user(self.dj) + else: + event["stderr"].write(f"I can't find an account for {self.dj}. Try manually putting in their nickname?") + return + topic = dj.get_setting("tilderadio-djtopic",None) + if topic is None: + event["stderr"].write(f"{dj.nickname} doesn't have a DJ topic set.") + return + event["stdout"].write(f"DJ topic for {dj.nickname}: {topic}") -- 2.34.1