diff --git a/DrBotIRC.py b/DrBotIRC.py index 6ee6f4c..b57775f 100644 --- a/DrBotIRC.py +++ b/DrBotIRC.py @@ -326,6 +326,15 @@ class DrBotIRC(irclib.IRC): return 'Module ' + modname + ' reload failed. Check the console.' + def list_modules(self): + """List loaded modules.""" + + modnames = [] + for module in self.modlist: + modnames.append(module.__class__.__name__) + + return modnames + # SIGINT signal handler def sigint_handler(self, signal, frame): for module in self.modlist: diff --git a/modules/IrcAdmin.py b/modules/IrcAdmin.py index 00d13f1..88371cb 100644 --- a/modules/IrcAdmin.py +++ b/modules/IrcAdmin.py @@ -78,6 +78,8 @@ class IrcAdmin(Module): return self.sub_reload_module(connection, event, nick, userhost, what, admin_unlocked) elif whats[0] == '!unload' and admin_unlocked and len(whats) >= 2: return self.sub_unload_module(connection, event, nick, userhost, what, admin_unlocked) + elif whats[0] == '!modules': + return self.sub_list_modules(connection, event, nick, userhost, what, admin_unlocked) def sub_join_channel(self, connection, event, nick, userhost, what, admin_unlocked): whats = what.split(' ') @@ -158,5 +160,10 @@ class IrcAdmin(Module): whats = what.split(' ') return self.irc.reload_module(whats[1]) + def sub_list_modules(self, connection, event, nick, userhost, what, admin_unlocked): + """Get the list of loaded modules from DrBotIRC and display it.""" + + return ', '.join(self.irc.list_modules()) + # vi:tabstop=4:expandtab:autoindent # kate: indent-mode python;indent-width 4;replace-tabs on;