summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/help.py2
-rw-r--r--modules/log.py10
-rw-r--r--modules/mysql.py10
3 files changed, 21 insertions, 1 deletions
diff --git a/modules/help.py b/modules/help.py
index d239f84..71d1a56 100644
--- a/modules/help.py
+++ b/modules/help.py
@@ -12,7 +12,7 @@ class Module(ModuleBase):
if not re.match(r'!help(?:\W|\Z)', message_body):
return
- commands = reduce(lambda l, mod: l + mod.commands(), self.manager.modules, [])
+ commands = reduce(lambda l, mod: l + mod.commands(), self.manager.modules.itervalues(), [])
helpstring = reduce(lambda s, (c, h): s + c + ': ' + h + '\n', commands, '')
reply('Befehle:\n\n' + helpstring)
diff --git a/modules/log.py b/modules/log.py
new file mode 100644
index 0000000..3280d27
--- /dev/null
+++ b/modules/log.py
@@ -0,0 +1,10 @@
+from base import ModuleBase
+
+class Module(ModuleBase):
+ def __init__(self, manager):
+ ModuleBase.__init__(self, manager)
+ self.db = manager.get('mysql').db
+
+ def groupchat(self, room, message_from, message_body, reply):
+ cursor = self.db.cursor()
+ cursor.execute('INSERT INTO log (time, room, nick, text) VALUES (NOW(), %s, %s, %s)', (room, message_from, message_body))
diff --git a/modules/mysql.py b/modules/mysql.py
new file mode 100644
index 0000000..3b6c3b1
--- /dev/null
+++ b/modules/mysql.py
@@ -0,0 +1,10 @@
+from base import ModuleBase
+import MySQLdb
+
+class Module(ModuleBase):
+ def __init__(self, manager):
+ ModuleBase.__init__(self, manager)
+
+ conf = manager.config['mysql']
+
+ self.db = MySQLdb.connect(host = conf['host'], user = conf['user'], passwd = conf['passwd'], db = conf['db'])