]> git.aero2k.de Git - urlbot-v3.git/commitdiff
mute functionality
authorThorsten S <mail@aero2k.de>
Wed, 12 May 2021 17:12:49 +0000 (19:12 +0200)
committerThorsten S <mail@aero2k.de>
Wed, 12 May 2021 17:12:49 +0000 (19:12 +0200)
distbot/bot/bot.py

index 009a397fb6c0f581f6e9c8961d287cb047dfa908..36b2a3ded5ed668fc9feddbcef2f02449b9e17ba 100644 (file)
@@ -36,6 +36,7 @@ class Bot(slixmpp.ClientXMPP):
             self.add_event_handler('muc::%s::got_online' % room, self.muc_online)
 
         self._initialize_plugins()
+        self.muted = False
 
     def _initialize_plugins(self):
         self.register_plugin('xep_0045')
@@ -127,6 +128,11 @@ class Bot(slixmpp.ClientXMPP):
         if msg['type'] in ('normal', 'chat', 'groupchat'):
             message = msg['body']
 
+            if message == f"{self.nick}: mute":
+                self.muted = True
+            elif message == f"{self.nick}: unmute":
+                self.muted = False
+
             if "hangup" in message:
                 self.disconnect()
 
@@ -137,6 +143,10 @@ class Bot(slixmpp.ClientXMPP):
                 self.initialize_actionworker()
                 self.echo("Worker One available for master.")
 
+            # TODO: still record stuff and react on things?
+            if self.muted:
+                return
+
             nick_offset, routing_key = self.get_amqp_routing_key(self.nick, msg)
 
             if msg["type"] == "groupchat":