From 2eb6112f2f92612ccaf1f2af8e2f36ccd1ea1385 Mon Sep 17 00:00:00 2001 From: Dabo Ross Date: Wed, 27 Nov 2013 03:17:04 -0800 Subject: [PATCH 1/2] Improve permissions checking --- plugins/core_sieve.py | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/plugins/core_sieve.py b/plugins/core_sieve.py index 3b00c4b..4a6c809 100644 --- a/plugins/core_sieve.py +++ b/plugins/core_sieve.py @@ -38,30 +38,21 @@ def sieve_suite(bot, input, func, kind, args): groups = bot.config.get("permissions", []) allowed_permissions = args.get('permissions', []) - allowed_groups = [] - - # loop over every group - for key, value in groups.iteritems(): - # loop over every permission the command allows - for permission in allowed_permissions: - # see if the group has that permission - print value - if permission in value["perms"]: - # if so, add the group name to the allowed_groups list - allowed_groups.append(key) - - if not allowed_groups: - print "Something is wrong. A hook requires {} but" \ - " there are no groups with that permission!".format(str(allowed_permissions)) mask = input.mask.lower() - for group in allowed_groups: - group_users = bot.config.get("permissions", {}).get(group, [])["users"] - group_users = [_mask.lower() for _mask in group_users] - for pattern in group_users: - if fnmatch(mask, pattern): - return input + # loop over every group + for key, group in groups.iteritems(): + # loop over every permission the command allows + for permission in allowed_permissions: + # see if the group has that permission + if permission in group["perms"]: + # if so, check it + group_users = [_mask.lower() for _mask in group["users"]] + for pattern in group_users: + if fnmatch(mask, pattern): + print "Allowed group {}.".format(group) + return input input.notice("Sorry, you are not allowed to use this command.") return None From 91c827a03b1dc503f5c0fadb1a354d71d04c4a64 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 1 Dec 2013 22:53:40 +1300 Subject: [PATCH 2/2] unfinished --- plugins/minecraft_bukkit.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/minecraft_bukkit.py b/plugins/minecraft_bukkit.py index 0ecc057..0c3313e 100644 --- a/plugins/minecraft_bukkit.py +++ b/plugins/minecraft_bukkit.py @@ -6,6 +6,9 @@ base_url = "http://api.bukget.org/3/" search_url = base_url + "search/plugin_name/like/{}" details_url = base_url + "plugins/bukkit/{}" +categories = http.get_json("http://api.bukget.org/3/categories") +total_plugins = sum([cat["count"] for cat in categories]) + class BukgetError(Exception): def __init__(self, code, text): @@ -54,6 +57,7 @@ def plugin_details(slug): def bukkitplugin(inp, reply=None, message=None): """plugin - Look up a plugin on dev.bukkit.org""" # get the plugin slug using search + print total_plugins try: slug = plugin_search(inp) except BukgetError as e: @@ -65,6 +69,7 @@ def bukkitplugin(inp, reply=None, message=None): except BukgetError as e: return e + name = data["plugin_name"] description = data['description'] url = data['website']