summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-07-21 21:58:49 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-07-21 21:58:49 +0200
commitcd01be4952a6ef00cf325e7a9f818872dc7dfcf0 (patch)
treeb2d0e89a5791f1bd556042fea4426685125d1cfd /modules
parent106f39d5b58cff3443eb19c7a4f3994cb1ba4d87 (diff)
downloadcurunir-cd01be4952a6ef00cf325e7a9f818872dc7dfcf0.tar
curunir-cd01be4952a6ef00cf325e7a9f818872dc7dfcf0.zip
Added fortune module
Diffstat (limited to 'modules')
-rw-r--r--modules/fortune.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/fortune.py b/modules/fortune.py
new file mode 100644
index 0000000..e7c999e
--- /dev/null
+++ b/modules/fortune.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+from . import ModuleBase
+import re, subprocess
+
+class Module(ModuleBase):
+ def __init__(self, manager):
+ ModuleBase.__init__(self, manager)
+
+ self.fortune = manager.config['fortune']
+
+
+ def commands(self):
+ return [('!fortune', 'Zeigt ein zufälliges Fortune Cookie an')]
+
+ def groupchat(self, room, nick, text, handler):
+ if not re.match(r'!fortune(?:\W|\Z)', text):
+ return
+
+ handler.reply(subprocess.Popen([self.fortune], stdout=subprocess.PIPE).communicate()[0].strip())