summaryrefslogtreecommitdiff
path: root/plugins/figlet.py
blob: 4d147956160a6f81d85518ade629c0f4337ba547 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
from plugin import BasePlugin
import subprocess

class Plugin(BasePlugin):
    def init(self):
        self.add_event_handler('muc_say', self.figletize)
        self.add_event_handler('conversation_say', self.figletize)
        self.add_event_handler('private_say', self.figletize)

    def figletize(self, msg, tab):
        process = subprocess.Popen(['figlet', msg['body']], stdout=subprocess.PIPE)
        result = process.communicate()[0].decode('utf-8')
        msg['body'] = result