From 472ba06b94b090c341c8073fff954692643dee18 Mon Sep 17 00:00:00 2001 From: randomuser Date: Wed, 11 Aug 2021 20:52:18 -0500 Subject: [PATCH] change default.py to have admin features --- mods/default.py | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/mods/default.py b/mods/default.py index 4717787..33e4774 100644 --- a/mods/default.py +++ b/mods/default.py @@ -1,22 +1,47 @@ import utils +# This file is part of modbot. + +# modbot is free software: you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public +# License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any +# later version. + +# modbot is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero +# General Public License along with modbot. If not, see +# . + def cmd(line, srv): command, params = utils.cmdparse(line) if command == "load": - try: - srv.load_mod(params[0]) - except ModuleNotFoundError: - utils.message(srv, line.params[0], - "failed to load `" + params[0] + "'") + if utils.is_admin(params[0]): + try: + srv.load_mod(params[0]) + except ModuleNotFoundError: + utils.message(srv, line.params[0], + "failed to load `" + params[0] + "'") + else: + utils.message(srv, line.params[0], + "loaded: `" + params[0] + "'") else: utils.message(srv, line.params[0], - "loaded: `" + params[0] + "'") + "invalid permissions!") elif command == "unload": - try: - srv.unload_mod(params[0]) - except: - utils.message(srv, line.params[0], - "failed to unload `" + params[0] + "'") + if utils.is_admin(params[0]): + try: + srv.unload_mod(params[0]) + except: + utils.message(srv, line.params[0], + "failed to unload `" + params[0] + "'") + else: + utils.message(srv, line.params[0], + "unloaded: `" + params[0] + "'" else: utils.message(srv, line.params[0], - "unloaded: `" + params[0] + "'" + "invalid permissions!")