]> jfr.im git - erebus.git/blob - modules/stafflist.py
admin_config - add !getconfig, remove some unused functions
[erebus.git] / modules / stafflist.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
3 # staff list module
4 # This file is released into the public domain; see http://unlicense.org/
5
6 # module info
7 modinfo = {
8 'author': 'Erebus Team',
9 'license': 'public domain',
10 'compatible': [0], # compatible module API versions
11 'depends': [], # other modules required to work properly?
12 'softdeps': ['help'], # modules which are preferred but not required
13 }
14
15 # preamble
16 import modlib
17 lib = modlib.modlib(__name__)
18 modstart = lib.modstart
19 modstop = lib.modstop
20
21 # module code
22 def _getnicks(auth):
23 nicks = [x.nick for x in lib.parent.getuserbyauth(auth)]
24 if len(nicks) == 0:
25 return 'not online'
26 else:
27 return ', '.join(nicks)
28
29 @lib.hook(needchan=False)
30 @lib.help(None, 'lists staff')
31 @lib.argsEQ(0)
32 def stafflist(bot, user, chan, realtarget, *args):
33 c = lib.parent.query("SELECT auth, level FROM users WHERE level > %s", (lib.parent.cfg.get('stafflist', 'minstafflevel', default=lib.KNOWN),))
34 if c:
35 staffs = c.fetchall()
36 c.close()
37 if len(staffs) > 0:
38 if user.glevel > lib.KNOWN:
39 response = ["#%s (%s, %s)" % (i['auth'], _getnicks(i['auth']), i['level']) for i in staffs]
40 else:
41 response = ["#%s (%s)" % (i['auth'], _getnicks(i['auth'])) for i in staffs]
42 user.msg("Staff listing: %s" % (', '.join(response)))
43 else:
44 user.msg("It's anarchy!")