]>
jfr.im git - erebus.git/blob - modules/admin_config.py
1 # Erebus IRC bot - Author: Erebus Team
2 # vim: fileencoding=utf-8
3 # Commands to change config file settings
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
28 @lib.hook(needchan
=False, glevel
=lib
.OWNER
)
29 @lib.help('<section> <key>', 'gets a current config file setting')
31 def getconfig(bot
, user
, chan
, realtarget
, *args
):
32 section
, key
= args
[0], args
[1]
33 value
= bot
.parent
.cfg
.get(section
, key
)
35 user
.msg('[%s] %s: %s' % (section
, key
, value
))
37 user
.msg('That option is not set ([%s] %s)' % (section
, key
))
39 @lib.hook(needchan
=False, glevel
=lib
.OWNER
)
40 @lib.help('<section> <key> <value>', 'sets a config file setting to a new value')
42 def setconfig(bot
, user
, chan
, realtarget
, *args
):
43 section
, key
, value
= args
[0], args
[1], ' '.join(args
[2:])
44 bot
.parent
.cfg
.set(section
, key
, value
)
45 return "Set `[%s] %s` to: %s" % (section
, key
, value
)
47 @lib.hook(needchan
=False, glevel
=lib
.OWNER
)
48 @lib.help('<section> <key>', 'deletes a config file setting')
50 def delconfig(bot
, user
, chan
, realtarget
, *args
):
51 section
, key
= args
[0], args
[1]
52 bot
.parent
.cfg
.delete(section
, key
)
53 return "Deleted `[%s] %s`" % (section
, key
)