Added fortune module
This commit is contained in:
parent
106f39d5b5
commit
cd01be4952
1 changed files with 20 additions and 0 deletions
20
modules/fortune.py
Normal file
20
modules/fortune.py
Normal file
|
@ -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())
|
Reference in a new issue