summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Sherson <caretaker82@euclid.shersonb.net>2013-08-27 20:41:00 -0700
committerBrian Sherson <caretaker82@euclid.shersonb.net>2013-08-27 20:41:00 -0700
commitf62fee63579ed5bdc1481a118720a1357dad9bee (patch)
tree962a5b57898f7d6a1bdedaaf4197f1e7236b9561
parent25ed9b71564b73b07d664e2396c641ffe74f45b1 (diff)
-rw-r--r--[l---------]cannon.py31
-rw-r--r--[l---------]figlet.py21
2 files changed, 50 insertions, 2 deletions
diff --git a/cannon.py b/cannon.py
index 1770271..3af725e 120000..100644
--- a/cannon.py
+++ b/cannon.py
@@ -1 +1,30 @@
-../cannon.py \ No newline at end of file
+#!/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
index 7d63417..8f88416 120000..100644
--- a/figlet.py
+++ b/figlet.py
@@ -1 +1,20 @@
-../figlet.py \ No newline at end of file
+#!/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()