aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-14 12:09:42 +0100
committerGravatar jesopo2019-06-14 12:09:42 +0100
commitf614d1fc1480724b2d5f2cb409ad8a1962173b74 (patch)
tree3123b15da131a473532c063914e807edfca34c96
parentAdd a way to __or__ `utils.Check`s, as a "if one of these passes" thing (diff)
signature
add `self` check.command, change !config to use new yields
-rw-r--r--modules/commands/__init__.py8
-rw-r--r--modules/config.py8
-rw-r--r--modules/stats.py2
3 files changed, 17 insertions, 1 deletions
diff --git a/modules/commands/__init__.py b/modules/commands/__init__.py
index 3b4dc74e..69b7201c 100644
--- a/modules/commands/__init__.py
+++ b/modules/commands/__init__.py
@@ -604,3 +604,11 @@ class Module(ModuleManager.BaseModule):
del aliases[alias]
self._set_aliases(event["server"], aliases)
event["stdout"].write("Removed '%s' alias" % alias)
+
+ @utils.hook("check.command.self")
+ def check_command_self(self, event):
+ if event["server"].irc_lower(event["request_args"][0]
+ ) == event["user"].name:
+ return utils.consts.PERMISSION_FORCE_SUCCESS
+ else:
+ return "You do not have permission to do this"
diff --git a/modules/config.py b/modules/config.py
index a6d06f3f..ba02f308 100644
--- a/modules/config.py
+++ b/modules/config.py
@@ -281,7 +281,6 @@ class Module(ModuleManager.BaseModule):
"""
:help: Change config options
:usage: <context>[:name] [-][setting [value]]
- :permission: config
"""
arg_count = len(event["args_split"])
@@ -297,12 +296,17 @@ class Module(ModuleManager.BaseModule):
target, context = self._to_context(event["server"],
event["target"], event["user"], context_desc)
+ permission_check = utils.Check("permission", "config")
+
if context == "set":
if name:
+ yield utils.Check("self", name)|permission_check
target = event["server"].get_user(name)
else:
target = event["user"]
elif context == "channelset":
+ yield utils.Check("channel-mode", "o")|permission_check
+
if name:
if name in event["server"].channels:
target = event["server"].channels.get(name)
@@ -316,6 +320,8 @@ class Module(ModuleManager.BaseModule):
raise utils.EventError(
"Cannot change config for current channel when in "
"private message")
+ elif context == "serverset" or context == "botset":
+ yield utils.Check("permission", "config")
export_settings = self._get_export_setting(context)
if not setting == None:
diff --git a/modules/stats.py b/modules/stats.py
index 1a1fcdae..5b497d39 100644
--- a/modules/stats.py
+++ b/modules/stats.py
@@ -31,6 +31,8 @@ class Module(ModuleManager.BaseModule):
"""
:help: Show my network/channel/user stats
"""
+ yield utils.Check("channel-mode", "o")|utils.Check("permission", "asd")
+
networks, channels, users = self._stats()
response = "I currently have %d network" % networks