]> jfr.im git - erebus.git/blobdiff - modules/stafflist.py
urls - fix error handling
[erebus.git] / modules / stafflist.py
index a825ef0740b022d576da3e18ac498169d1ca5dd4..1c62b5d6e92cd54e93123e05e917688d7f31ab70 100644 (file)
@@ -1,4 +1,5 @@
 # Erebus IRC bot - Author: Erebus Team
+# vim: fileencoding=utf-8
 # staff list module
 # This file is released into the public domain; see http://unlicense.org/
 
@@ -18,17 +19,26 @@ modstart = lib.modstart
 modstop = lib.modstop
 
 # module code
+def _getnicks(auth):
+       nicks = [x.nick for x in lib.parent.getuserbyauth(auth)]
+       if len(nicks) == 0:
+               return 'not online'
+       else:
+               return ', '.join(nicks)
+
 @lib.hook(needchan=False)
 @lib.help(None, 'lists staff')
 @lib.argsEQ(0)
 def stafflist(bot, user, chan, realtarget, *args):
-       c = lib.parent.query("SELECT auth, level FROM users WHERE level > %s", (lib.parent.cfg.get('stafflist', 'minstafflevel', default=lib.KNOWN)))
+       c = lib.parent.query("SELECT auth, level FROM users WHERE level > %s", (lib.parent.cfg.get('stafflist', 'minstafflevel', default=lib.KNOWN),))
        if c:
                staffs = c.fetchall()
                c.close()
                if len(staffs) > 0:
                        if user.glevel > lib.KNOWN:
-                               response = ["%s (%s)" % (i['auth'], i['level']) for i in staffs]
+                               response = ["#%s (%s, %s)" % (i['auth'], _getnicks(i['auth']), i['level']) for i in staffs]
                        else:
-                               response = [i['auth'] for i in staffs]
+                               response = ["#%s (%s)" % (i['auth'], _getnicks(i['auth'])) for i in staffs]
                        user.msg("Staff listing: %s" % (', '.join(response)))
+       else:
+               user.msg("It's anarchy!")