From 9c8cf8fa2855419067c28293d508366241fd834b Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 26 Jul 2013 11:30:03 +0200 Subject: initial commit --- .gitignore | 1 + pipe_notify.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 .gitignore create mode 100644 pipe_notify.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/pipe_notify.py b/pipe_notify.py new file mode 100644 index 0000000..2436e40 --- /dev/null +++ b/pipe_notify.py @@ -0,0 +1,32 @@ +#!/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) -- cgit v1.2.3-1-g7c22