]> jfr.im git - erebus.git/blame - modules/admin_config.py
admin_config - add !getconfig, remove some unused functions
[erebus.git] / modules / admin_config.py
CommitLineData
017b57a0
JR
1# Erebus IRC bot - Author: Erebus Team
2# vim: fileencoding=utf-8
bac69af4 3# Commands to change config file settings
017b57a0
JR
4# This file is released into the public domain; see http://unlicense.org/
5
6# module info
7modinfo = {
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# 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.
16#
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
19
20# preamble
21import modlib
22lib = modlib.modlib(__name__)
23modstart = lib.modstart
24modstop = lib.modstop
25
26# module code
27
b614c53f
JR
28@lib.hook(needchan=False, glevel=lib.OWNER)
29@lib.help('<section> <key>', 'gets a current config file setting')
30@lib.argsEQ(2)
31def getconfig(bot, user, chan, realtarget, *args):
32 section, key = args[0], args[1]
33 value = bot.parent.cfg.get(section, key)
34 if value is not None:
35 user.msg('[%s] %s: %s' % (section, key, value))
017b57a0 36 else:
b614c53f 37 user.msg('That option is not set ([%s] %s)' % (section, key))
017b57a0
JR
38
39@lib.hook(needchan=False, glevel=lib.OWNER)
40@lib.help('<section> <key> <value>', 'sets a config file setting to a new value')
41@lib.argsGE(3)
42def 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)
46
47@lib.hook(needchan=False, glevel=lib.OWNER)
48@lib.help('<section> <key>', 'deletes a config file setting')
49@lib.argsEQ(2)
50def 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)