change default.py to have admin features

This commit is contained in:
randomuser 2021-08-11 20:52:18 -05:00
parent f8b129b2d1
commit 472ba06b94
1 changed files with 37 additions and 12 deletions

View File

@ -1,8 +1,26 @@
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
# <https://www.gnu.org/licenses/>.
def cmd(line, srv):
command, params = utils.cmdparse(line)
if command == "load":
if utils.is_admin(params[0]):
try:
srv.load_mod(params[0])
except ModuleNotFoundError:
@ -11,7 +29,11 @@ def cmd(line, srv):
else:
utils.message(srv, line.params[0],
"loaded: `" + params[0] + "'")
else:
utils.message(srv, line.params[0],
"invalid permissions!")
elif command == "unload":
if utils.is_admin(params[0]):
try:
srv.unload_mod(params[0])
except:
@ -20,3 +42,6 @@ def cmd(line, srv):
else:
utils.message(srv, line.params[0],
"unloaded: `" + params[0] + "'"
else:
utils.message(srv, line.params[0],
"invalid permissions!")