This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
curunir/modules/fortune.py

21 lines
583 B
Python
Raw Normal View History

2010-07-21 21:58:49 +02:00
# -*- 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())