diff --git a/mods/default.py b/mods/default.py index 8eea45a..6c382b3 100644 --- a/mods/default.py +++ b/mods/default.py @@ -1,9 +1,13 @@ import utils def cmd(line, srv): - splitted = line.params[1].split(' ') - command = splitted[0][1:] + command, params = utils.cmdparse(line) if command == "load": - srv.load_mod(splitted[1]) - utils.message(srv, line.params[0], - "loaded: " + splitted[1]) + 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] + "'") diff --git a/mods/utils.py b/mods/utils.py index ee1fdcc..16f8342 100644 --- a/mods/utils.py +++ b/mods/utils.py @@ -18,3 +18,12 @@ from irctokens import build def message(srv, channel, msg): srv.send(build("PRIVMSG", [channel, msg])) + +def cmdparse(line): + splitted = line.params[1].split(' ') + try: command = splitted[0][1:] + except IndexError: command = None + try: params = splitted[1:] + except IndexError: params = None + return (command, params) +