From 5bb96c0d0c9f4f7acdc5325fdb3ac4d96c975df5 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sun, 18 Nov 2018 07:55:43 +0000 Subject: [PATCH] Added modules/factoid.py --- modules/factoids.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 modules/factoids.py diff --git a/modules/factoids.py b/modules/factoids.py new file mode 100644 index 00000000..691b6b3d --- /dev/null +++ b/modules/factoids.py @@ -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))