--- /dev/null
+# Erebus IRC bot - Author: Erebus Team
+# vim: fileencoding=utf-8
+# simple module example
+# This file is released into the public domain; see http://unlicense.org/
+
+# module info
+modinfo = {
+ 'author': 'Erebus Team',
+ 'license': 'public domain',
+ 'compatible': [0], # compatible module API versions
+ 'depends': [], # other modules required to work properly?
+ 'softdeps': ['help'], # modules which are preferred but not required
+}
+# note: softdeps will be loaded before this module, IF not disabled in the configuration (autoload.module = 0) (and if it exists)
+# 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.
+#
+# basically, softdeps are things this module will use if available, but does not require (no errors will occur if it's not loaded)
+# for example, @lib.help() will attempt to use the help module, but swallow errors if it is not loaded
+
+# preamble
+import modlib
+lib = modlib.modlib(__name__)
+modstart = lib.modstart
+modstop = lib.modstop
+
+# module code
+
+def _resolve_user(s):
+ if s.startswith("#"):
+ return lib.parent.User(s, s[1:])
+ else:
+ return lib.parent.user(s, create=False)
+
+def _resolve_level(s):
+ try:
+ i = int(s)
+ return i
+ except ValueError:
+ su = s.upper()
+ if su == "ANYONE":
+ su = "AUTHED" # resolve to 0 instead of -1
+ if su in lib.glevs:
+ return lib.glevs[su]
+ return None
+
+@lib.hook(needchan=False, glevel=lib.OWNER)
+@lib.help('<section> <key> <value>', 'sets a config file setting to a new value')
+@lib.argsGE(3)
+def setconfig(bot, user, chan, realtarget, *args):
+ section, key, value = args[0], args[1], ' '.join(args[2:])
+ bot.parent.cfg.set(section, key, value)
+ return "Set `[%s] %s` to: %s" % (section, key, value)
+
+@lib.hook(needchan=False, glevel=lib.OWNER)
+@lib.help('<section> <key>', 'deletes a config file setting')
+@lib.argsEQ(2)
+def delconfig(bot, user, chan, realtarget, *args):
+ section, key = args[0], args[1]
+ bot.parent.cfg.delete(section, key)
+ return "Deleted `[%s] %s`" % (section, key)