]>
jfr.im git - erebus.git/blob - modules/admin_config.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
3 # simple module example
4 # This file is released into the public domain; see http://unlicense.org/
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
14 # note: softdeps will be loaded before this module, IF not disabled in the configuration (autoload.module = 0) (and if it exists)
15 # however, if it is disabled it will be silently ignored, and if it is unloaded at runtime it won't cause this one to unload.
17 # basically, softdeps are things this module will use if available, but does not require (no errors will occur if it's not loaded)
18 # for example, @lib.help() will attempt to use the help module, but swallow errors if it is not loaded
22 lib
= modlib
.modlib(__name__
)
23 modstart
= lib
.modstart
30 return lib
.parent
.User(s
, s
[1:])
32 return lib
.parent
.user(s
, create
=False)
34 def _resolve_level(s
):
41 su
= "AUTHED" # resolve to 0 instead of -1
46 @lib.hook(needchan
=False, glevel
=lib
.OWNER
)
47 @lib.help('<section> <key> <value>', 'sets a config file setting to a new value')
49 def setconfig(bot
, user
, chan
, realtarget
, *args
):
50 section
, key
, value
= args
[0], args
[1], ' '.join(args
[2:])
51 bot
.parent
.cfg
.set(section
, key
, value
)
52 return "Set `[%s] %s` to: %s" % (section
, key
, value
)
54 @lib.hook(needchan
=False, glevel
=lib
.OWNER
)
55 @lib.help('<section> <key>', 'deletes a config file setting')
57 def delconfig(bot
, user
, chan
, realtarget
, *args
):
58 section
, key
= args
[0], args
[1]
59 bot
.parent
.cfg
.delete(section
, key
)
60 return "Deleted `[%s] %s`" % (section
, key
)