Added ddate module
This commit is contained in:
parent
d537d4b69b
commit
e732bdadf5
2 changed files with 16 additions and 0 deletions
15
modules/ddate.py
Normal file
15
modules/ddate.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from base import ModuleBase
|
||||||
|
import re, subprocess
|
||||||
|
|
||||||
|
class Module(ModuleBase):
|
||||||
|
def __init__(self, manager):
|
||||||
|
ModuleBase.__init__(self, manager)
|
||||||
|
|
||||||
|
def commands(self):
|
||||||
|
return [('!ddate', 'Das heutige Datum im einzigen relevaten Kalender-System.')]
|
||||||
|
|
||||||
|
def groupchat(self, room, message_from, message_body, reply):
|
||||||
|
if not re.match(r'!ddate(?:\W|\Z)', message_body):
|
||||||
|
return
|
||||||
|
|
||||||
|
reply(subprocess.Popen(['ddate'], stdout=subprocess.PIPE).communicate()[0].strip())
|
|
@ -8,3 +8,4 @@ class Module(ModuleBase):
|
||||||
def groupchat(self, room, message_from, message_body, reply):
|
def groupchat(self, room, message_from, message_body, reply):
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute('INSERT INTO log (time, room, nick, text) VALUES (NOW(), %s, %s, %s)', (room, message_from, message_body))
|
cursor.execute('INSERT INTO log (time, room, nick, text) VALUES (NOW(), %s, %s, %s)', (room, message_from, message_body))
|
||||||
|
cursor.close()
|
||||||
|
|
Reference in a new issue