poezio/plugins/figlet.py

14 lines
505 B
Python
Raw Normal View History

2011-11-06 22:46:35 +00:00
from plugin import BasePlugin
import subprocess
class Plugin(BasePlugin):
def init(self):
self.add_poezio_event_handler('muc_say', self.figletize)
self.add_poezio_event_handler('conversation_say', self.figletize)
self.add_poezio_event_handler('private_say', self.figletize)
2011-11-06 22:46:35 +00:00
def figletize(self, msg):
process = subprocess.Popen(['figlet', msg['body']], stdout=subprocess.PIPE)
result = process.communicate()[0].decode('utf-8')
msg['body'] = result