#!/usr/bin/env python """ pipe_notify.py - Phenny Pipe Notification Copyright 2013, Alexander Sulfrian Licensed under the Eiffel Forum License 2. http://inamidst.com/phenny/ """ import os, fcntl, threading PIPE_PATH = os.path.join('/', 'var', 'run', 'phenny', 'pipe') def setup(phenny): dir = os.path.dirname(PIPE_PATH) if not os.path.exists(dir): os.makedirs(dir) t = threading.Thread(target=monitor_pipe, args=(phenny, PIPE_PATH,)) t.start() def monitor_pipe(phenny, name): if not os.path.exists(name): prev = os.umask(0o000) os.mkfifo(name) os.umask(prev) while True: fifo = open(name, 'r') for line in fifo: for chan in phenny.config.channels: phenny.msg(chan, line)