From f62fee63579ed5bdc1481a118720a1357dad9bee Mon Sep 17 00:00:00 2001 From: Brian Sherson Date: Tue, 27 Aug 2013 20:41:00 -0700 Subject: --- cannon.py | 31 ++++++++++++++++++++++++++++++- figlet.py | 21 ++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) mode change 120000 => 100644 cannon.py mode change 120000 => 100644 figlet.py diff --git a/cannon.py b/cannon.py deleted file mode 120000 index 1770271..0000000 --- a/cannon.py +++ /dev/null @@ -1 +0,0 @@ -../cannon.py \ No newline at end of file diff --git a/cannon.py b/cannon.py new file mode 100644 index 0000000..3af725e --- /dev/null +++ b/cannon.py @@ -0,0 +1,30 @@ +#!/usr/bin/python + +import re, os + +class Cannon(object): + def __init__(self): + self.firecount={} + def onRecv(self, IRC, line, data): + if data==None: return + (origin, ident, host, cmd, target, params, extinfo)=data + if len(target) and target[0]=="#" and cmd=="PRIVMSG": + channel=IRC.channel(target) + matches=re.findall("^!fire\\s+(.*)$",extinfo) + if matches: + nickname=matches[0] + if any([nickname.lower()==user.nick.lower() for user in channel.users]): + user=IRC.user(nickname) + if user in self.firecount.keys(): + count=self.firecount[user]+1 + else: + count=1 + self.firecount[user]=count + if 10<=count%100<20: ordinal="th" + elif count%10==1: ordinal="st" + elif count%10==2: ordinal="nd" + elif count%10==3: ordinal="rd" + else: ordinal="th" + channel.me("fires %s out of a cannon for the %d%s time."%(user.nick, count, ordinal)) + else: + channel.msg("%s: I cannot fire %s out of a cannon, as he or she is not here."%(origin, nickname)) diff --git a/figlet.py b/figlet.py deleted file mode 120000 index 7d63417..0000000 --- a/figlet.py +++ /dev/null @@ -1 +0,0 @@ -../figlet.py \ No newline at end of file diff --git a/figlet.py b/figlet.py new file mode 100644 index 0000000..8f88416 --- /dev/null +++ b/figlet.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +import re, os + +class Figlet(object): + def onRecv(self, IRC, line, data): + if data==None: return + (origin, ident, host, cmd, target, params, extinfo)=data + if len(target) and target[0]=="#" and cmd=="PRIVMSG": + channel=IRC.channel(target) + matches=re.findall("^!figlet\\s+(.*)$",extinfo) + if matches: + gif,fig=os.popen2("figlet") + gif.write(matches[0]) + gif.close() + while True: + line=fig.readline() + if line=="": break + if re.match("^\\s+$", line.rstrip()): continue + channel.msg(line.rstrip()) + fig.close() -- cgit v1.2.3