aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-09-17 10:53:40 +0100
committerGravatar jesopo2019-09-17 10:54:07 +0100
commite77124604c491f239e44c63090ef47c59ece0d6e (patch)
tree1b38710e9515f4e6217dd03052f699679775e396 /modules
parentadd per-channel default mumble server (diff)
signature
hide hidden channels from "!channels" when not pm and not current channel
closes #150
Diffstat (limited to 'modules')
-rw-r--r--modules/stats.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/stats.py b/modules/stats.py
index 70b24497..acf85ac1 100644
--- a/modules/stats.py
+++ b/modules/stats.py
@@ -3,6 +3,8 @@
import time
from src import ModuleManager, utils
+HIDDEN_MODES = set(["s", "p"])
+
class Module(ModuleManager.BaseModule):
def _uptime(self):
return utils.to_pretty_time(int(time.time()-self.bot.start_time))
@@ -139,8 +141,16 @@ class Module(ModuleManager.BaseModule):
@utils.kwarg("help", "List all the channel I'm in on this network")
@utils.kwarg("permission", "listchannels")
def channels_command(self, event):
+ channels = []
+ for channel in event["server"].channels.values():
+ hidden = bool(HIDDEN_MODES&set(channel.modes.keys()))
+ if hidden and (
+ event["is_channel"] and not channel == event["target"]):
+ continue
+ channels.append(channel.name)
+
event["stdout"].write("Current channels: %s" %
- " ".join(event["server"].channels.keys()))
+ " ".join(sorted(channels)))
@utils.hook("api.get.modules")
def modules_api(self, event):