From 045abfa9c152a9abad22b9d66f151a2f8eb24b53 Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 16 Dec 2016 18:31:19 -0800 Subject: [PATCH] commands: add permissions checks to echo, showuser, showchan, and status --- example-permissions.yml | 3 +++ plugins/commands.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/example-permissions.yml b/example-permissions.yml index 310060c..b8575e4 100644 --- a/example-permissions.yml +++ b/example-permissions.yml @@ -39,6 +39,9 @@ permissions: "*!*@*": # The following permissions are given to all users by default. - relay.linked + - commands.status + - commands.showuser + - commands.showchan # Replace ABC123 with your PyLink account name (configured above) # in order to give yourself admin access. diff --git a/plugins/commands.py b/plugins/commands.py index c562433..fd5af54 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -5,11 +5,23 @@ from pylinkirc import utils, __version__, world, real_version from pylinkirc.log import log from pylinkirc.coremods import permissions +default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan']} + +def main(irc=None): + """Commands plugin main function, called on plugin load.""" + # Register our permissions. + permissions.addDefaultPermissions(default_permissions) + +def die(irc): + """Commands plugin die function, called on plugin unload.""" + permissions.removeDefaultPermissions(default_permissions) + @utils.add_cmd def status(irc, source, args): """takes no arguments. Returns your current PyLink login status.""" + permissions.checkPermissions(irc, source, ['commands.status']) identified = irc.users[source].account if identified: irc.reply('You are identified as \x02%s\x02.' % identified) @@ -23,6 +35,7 @@ def showuser(irc, source, args): """ Shows information about .""" + permissions.checkPermissions(irc, source, ['commands.showuser']) try: target = args[0] except IndexError: @@ -66,6 +79,7 @@ def showchan(irc, source, args): """ Shows information about .""" + permissions.checkPermissions(irc, source, ['commands.showchan']) try: channel = irc.toLower(args[0]) except IndexError: @@ -126,6 +140,7 @@ def echo(irc, source, args): """ Echoes the text given.""" + permissions.checkPermissions(irc, source, ['commands.echo']) irc.reply(' '.join(args)) loglevels = {'DEBUG': 10, 'INFO': 20, 'WARNING': 30, 'ERROR': 40, 'CRITICAL': 50}