* Fixed bantracker webinterface

* Added authorinfo to factoids
* Added hhgttg quotes and magic 8ball to the mess plugin
* Enabled ubotu, tell ... again
This commit is contained in:
Dennis Kaarsemaker 2006-07-02 11:40:22 +02:00
parent 2c765dbeed
commit 0907c8e74b
5 changed files with 59 additions and 15 deletions

View File

@ -311,7 +311,7 @@ for b in bans[start:end]:
# Operator
print '<td>%s' % b[2]
if b[4]: # Ban removal
print '<br /><span class="removal">%s</span>' % b[5]
print u'<br /><span class="removal">%s</span>' % b[5]
print '</td>'
# Time
print '<td>%s' % pickle.loads(b[3]).astimezone(tz).strftime("%b %d %Y %H:%M:%S")
@ -334,8 +334,9 @@ for b in bans[start:end]:
print '<span class="removal">(No comments) </span>'
else:
for c in comments:
print '%s <span class="removal"><br />%s, %s</span><br />' % \
(q(c[1]),c[0],pickle.loads(c[2]).astimezone(tz).strftime("%b %d %Y %H:%M:%S"))
print q(c[1])
print u' <span class="removal"><br />%s, %s</span><br />' % \
(c[0],pickle.loads(c[2]).astimezone(tz).strftime("%b %d %Y %H:%M:%S"))
print """<span class="pseudolink" onclick="toggle('%s','comment')">Add comment</span>""" % b[6]
print """<div class="invisible" id="comment_%s"><br />""" % b[6]
print """<form action="bans.cgi" method="POST"><textarea cols="50" rows="5" class="input" name="comment"></textarea><br />"""

View File

@ -71,11 +71,12 @@ class Encyclopedia(callbacks.PluginRegexp):
self.seens = {}
# Capability check
def _precheck(self, irc, msg, capability=None, timeout=None):
def _precheck(self, irc, msg, capability=None, timeout=None, withnick=False):
channel = msg.args[0].lower()
inchannel = channel.startswith('#')
excl = msg.args[1].startswith('!')
if inchannel and not excl:
wn = msg.args[1].startswith('ubotu')
if inchannel and not (excl or (wn and withnick)):
return False
for c in irc.callbacks:
comm = msg.args[1].split()[0]
@ -131,8 +132,9 @@ class Encyclopedia(callbacks.PluginRegexp):
irc.error('An error occured (code 561)')
def showfactoid(self, irc, msg, match):
r"^(!|ubotu\S?\s)?(?P<noalias>-)?\s*(tell\s+(?P<nick>\S+)\s+about\s+)?(?P<factoid>\S.*?)(>\s*(?P<nick2>\S+))?$"
db = self._precheck(irc, msg, timeout=(msg.args[0], match.group('nick'), match.group('factoid'), match.group('nick2')))
r"^(!|!?ubotu\S?\s)?(?P<noalias>-)?\s*(tell\s+(?P<nick>\S+)\s+about\s+)?(?P<factoid>\S.+?)(>\s*(?P<nick2>\S+))?$"
withnick = bool(match.group(1)) and msg.args[1].startswith('ubotu')
db = self._precheck(irc, msg, withnick=True, timeout=(msg.args[0], match.group('nick'), match.group('factoid'), match.group('nick2')))
if not db: return
to = channel = msg.args[0]
if channel[0] != '#':
@ -178,11 +180,21 @@ class Encyclopedia(callbacks.PluginRegexp):
if not noalias:
factoid = resolve_alias(db,factoid,channel)
else:
if not self._precheck(irc, msg, timeout=(to,factoid.name,1)):
return
cur.execute("SELECT name FROM facts WHERE value = %s", '<alias> ' + factoid.name)
data = cur.fetchall()
if(len(data)):
irc.queueMsg(ircmsgs.privmsg(to, "%s aliases: %s" % (factoid.name, ', '.join([x[0].strip() for x in data]))))
return
#irc.queueMsg(ircmsgs.privmsg(to, "%s aliases: %s" % (factoid.name, ', '.join([x[0].strip() for x in data]))))
aliases = "%s aliases: %s" % (factoid.name, ', '.join([x[0].strip() for x in data]))
else:
if factoid.value.strip().startswith('<alias>'):
aliases = "%s is %s" % (factoid.name, factoid.value.strip())
else:
aliases = "%s has no aliases" % factoid.name
authorinfo = "Added by %s on %s" % (factoid.author[:factoid.author.find('!')], factoid.added[:factoid.added.find('.')])
irc.queueMsg(ircmsgs.privmsg(to,"%s - %s" % (aliases, authorinfo)))
return
# Do timing
if not self._precheck(irc, msg, timeout=(to,factoid.name)):
return

View File

@ -8,11 +8,15 @@ import supybot.ircmsgs as ircmsgs
_bofhfile = '/home/dennis/ubugtu/plugins/Mess/bofh.txt'
_bofhdata = [x.strip() for x in open(_bofhfile).readlines()]
_42file = '/home/dennis/ubugtu/plugins/Mess/42.txt'
_42data = [x.strip() for x in open(_42file).readlines()]
_ballfile = '/home/dennis/ubugtu/plugins/Mess/ball.txt'
_balldata = [x.strip() for x in open(_ballfile).readlines()]
class Mess(callbacks.PluginRegexp):
"""Random Mess plugin"""
threaded = True
regexps = ['hugme']
regexps = ['hugme','r42','ball']
hugs = ["hugs %s","gives %s a big hug","gives %s a sloppy wet kiss",
"huggles %s","squeezes %s","humps %s"]
regex = re.compile('</h1>.*?<p>(.*?)</p>', re.DOTALL)
@ -176,6 +180,21 @@ class Mess(callbacks.PluginRegexp):
i = random.randint(0,len(_bofhdata)-1)
irc.reply("BOFH excuse #%d: %s" % (i, _bofhdata[i]))
bofh = wrap(bofh, [additional('int')])
def r42(self, irc, msg, match):
"""^@42$"""
if not self.ok(msg.args[0]): return
#if num and num >= 1 and num <= len(_bofhdata):
# i = num
#else:
i = random.randint(0,len(_42data)-1)
irc.reply(_42data[i])
def ball(self, irc, msg, match):
"""^magic 8ball.*\?$"""
if not self.ok(msg.args[0]): return
i = random.randint(0,len(_balldata)-1)
irc.reply(_balldata[i])
def bauer(self, irc, msg, args, count=0):
""" Display a Jack Bauer fact """

View File

@ -46,7 +46,7 @@ li {
list-style: none;
}
table {
width: 100%%;
width: 100%;
padding-top: 1em;
clear: both;
}

View File

@ -8,12 +8,21 @@ if os.environ.has_key('HTTP_COOKIE'):
cookie.load(os.environ['HTTP_COOKIE'])
if cookie.has_key('sess'):
cookie['sess']['max-age'] = 2592000
cookie['sess']['max-age'] = 2592000 * 3
cookie['sess']['version'] = 1
if cookie.has_key('tz'):
cookie['tz']['max-age'] = 2592000
cookie['tz']['max-age'] = 2592000 * 3
cookie['tz']['version'] = 1
sys.stdout = StringIO.StringIO()
class IOWrapper:
def __init__(self):
self.buf = []
def write(self, val):
self.buf.append(val)
def getvalue(self):
return self.buf
sys.stdout = IOWrapper()
def send_page(template):
data = sys.stdout.getvalue()
@ -25,7 +34,10 @@ def send_page(template):
fd = open(template)
tmpl = fd.read()
fd.close()
print tmpl % data
print tmpl[:tmpl.find('%s')]
for d in data:
print d
print tmpl[tmpl.find('%s')+2:]
sys.exit(0)
def q(txt):