Added modules/factoid.py

This commit is contained in:
jesopo 2018-11-18 07:55:43 +00:00
parent 870c56cfbb
commit 5bb96c0d0c

18
modules/factoids.py Normal file
View file

@ -0,0 +1,18 @@
from src import ModululeManager, utils
class Module(ModuleManager.BaseModule):
@utils.hook("received.command.factoid", min_args=1)
def factoid(self, event):
if "=" in event["args"]:
key, _, value = event["args"].partition("=")
factoid = key.lower().strip()
event["server"].set_setting("factoid-" % factoid, value.strip())
event["stdout"].write("Set factoid '%s'" % factoid)
else:
factoid = event["args"].lower().strip()
value = event["server"].get_setting("factoid-%s" % factoid, None)
if value == None:
raise utils.EventError("Unknown factoid '%s'" % factoid)
event["stdout"].write("%s: %s" % (factoid, value))