Created
September 24, 2012 01:33
-
-
Save agrif/3773742 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import phosphorus | |
from phosphorus.irc import IRC | |
import sys | |
_, host, port, nick = sys.argv | |
def main(): | |
irc = IRC(host, port, nick) | |
yield phosphorus.fork(irc.run()) | |
yield phosphorus.until_elapsed(2) | |
yield from irc.send_command("join", "#overviewer") | |
while 1: | |
cmd = (yield from irc.get_next_command('privmsg')) | |
if not cmd: | |
break | |
source, message = cmd[1] | |
if source == "#overviewer": | |
if "fnord" in message.lower(): | |
yield from irc.send_command("privmsg", "#overviewer", message.lower().replace("fnord", "")) | |
phosphorus.run(main()) |
Author
agrif
commented
Sep 24, 2012
class TimeCondition(Condition):
def __init__(self, end_time):
super(TimeCondition, self).__init__()
self.end_time = end_time
def is_fulfilled(self, rlist, wlist, xlist):
return time.time() >= self.end_time
def get_max_timeout(self):
return self.end_time - time.time()
def until_elapsed(seconds):
return TimeCondition(time.time() + seconds)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment