* 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:
parent
2c765dbeed
commit
0907c8e74b
|
@ -311,7 +311,7 @@ for b in bans[start:end]:
|
||||||
# Operator
|
# Operator
|
||||||
print '<td>%s' % b[2]
|
print '<td>%s' % b[2]
|
||||||
if b[4]: # Ban removal
|
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>'
|
print '</td>'
|
||||||
# Time
|
# Time
|
||||||
print '<td>%s' % pickle.loads(b[3]).astimezone(tz).strftime("%b %d %Y %H:%M:%S")
|
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>'
|
print '<span class="removal">(No comments) </span>'
|
||||||
else:
|
else:
|
||||||
for c in comments:
|
for c in comments:
|
||||||
print '%s <span class="removal"><br />%s, %s</span><br />' % \
|
print q(c[1])
|
||||||
(q(c[1]),c[0],pickle.loads(c[2]).astimezone(tz).strftime("%b %d %Y %H:%M:%S"))
|
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 """<span class="pseudolink" onclick="toggle('%s','comment')">Add comment</span>""" % b[6]
|
||||||
print """<div class="invisible" id="comment_%s"><br />""" % 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 />"""
|
print """<form action="bans.cgi" method="POST"><textarea cols="50" rows="5" class="input" name="comment"></textarea><br />"""
|
||||||
|
|
|
@ -71,11 +71,12 @@ class Encyclopedia(callbacks.PluginRegexp):
|
||||||
self.seens = {}
|
self.seens = {}
|
||||||
|
|
||||||
# Capability check
|
# 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()
|
channel = msg.args[0].lower()
|
||||||
inchannel = channel.startswith('#')
|
inchannel = channel.startswith('#')
|
||||||
excl = msg.args[1].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
|
return False
|
||||||
for c in irc.callbacks:
|
for c in irc.callbacks:
|
||||||
comm = msg.args[1].split()[0]
|
comm = msg.args[1].split()[0]
|
||||||
|
@ -131,8 +132,9 @@ class Encyclopedia(callbacks.PluginRegexp):
|
||||||
irc.error('An error occured (code 561)')
|
irc.error('An error occured (code 561)')
|
||||||
|
|
||||||
def showfactoid(self, irc, msg, match):
|
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+))?$"
|
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')))
|
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
|
if not db: return
|
||||||
to = channel = msg.args[0]
|
to = channel = msg.args[0]
|
||||||
if channel[0] != '#':
|
if channel[0] != '#':
|
||||||
|
@ -178,11 +180,21 @@ class Encyclopedia(callbacks.PluginRegexp):
|
||||||
if not noalias:
|
if not noalias:
|
||||||
factoid = resolve_alias(db,factoid,channel)
|
factoid = resolve_alias(db,factoid,channel)
|
||||||
else:
|
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)
|
cur.execute("SELECT name FROM facts WHERE value = %s", '<alias> ' + factoid.name)
|
||||||
data = cur.fetchall()
|
data = cur.fetchall()
|
||||||
if(len(data)):
|
if(len(data)):
|
||||||
irc.queueMsg(ircmsgs.privmsg(to, "%s aliases: %s" % (factoid.name, ', '.join([x[0].strip() for x in data]))))
|
#irc.queueMsg(ircmsgs.privmsg(to, "%s aliases: %s" % (factoid.name, ', '.join([x[0].strip() for x in data]))))
|
||||||
return
|
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
|
# Do timing
|
||||||
if not self._precheck(irc, msg, timeout=(to,factoid.name)):
|
if not self._precheck(irc, msg, timeout=(to,factoid.name)):
|
||||||
return
|
return
|
||||||
|
|
|
@ -8,11 +8,15 @@ import supybot.ircmsgs as ircmsgs
|
||||||
|
|
||||||
_bofhfile = '/home/dennis/ubugtu/plugins/Mess/bofh.txt'
|
_bofhfile = '/home/dennis/ubugtu/plugins/Mess/bofh.txt'
|
||||||
_bofhdata = [x.strip() for x in open(_bofhfile).readlines()]
|
_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):
|
class Mess(callbacks.PluginRegexp):
|
||||||
"""Random Mess plugin"""
|
"""Random Mess plugin"""
|
||||||
threaded = True
|
threaded = True
|
||||||
regexps = ['hugme']
|
regexps = ['hugme','r42','ball']
|
||||||
hugs = ["hugs %s","gives %s a big hug","gives %s a sloppy wet kiss",
|
hugs = ["hugs %s","gives %s a big hug","gives %s a sloppy wet kiss",
|
||||||
"huggles %s","squeezes %s","humps %s"]
|
"huggles %s","squeezes %s","humps %s"]
|
||||||
regex = re.compile('</h1>.*?<p>(.*?)</p>', re.DOTALL)
|
regex = re.compile('</h1>.*?<p>(.*?)</p>', re.DOTALL)
|
||||||
|
@ -176,6 +180,21 @@ class Mess(callbacks.PluginRegexp):
|
||||||
i = random.randint(0,len(_bofhdata)-1)
|
i = random.randint(0,len(_bofhdata)-1)
|
||||||
irc.reply("BOFH excuse #%d: %s" % (i, _bofhdata[i]))
|
irc.reply("BOFH excuse #%d: %s" % (i, _bofhdata[i]))
|
||||||
bofh = wrap(bofh, [additional('int')])
|
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):
|
def bauer(self, irc, msg, args, count=0):
|
||||||
""" Display a Jack Bauer fact """
|
""" Display a Jack Bauer fact """
|
||||||
|
|
2
bot.css
2
bot.css
|
@ -46,7 +46,7 @@ li {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
table {
|
table {
|
||||||
width: 100%%;
|
width: 100%;
|
||||||
padding-top: 1em;
|
padding-top: 1em;
|
||||||
clear: both;
|
clear: both;
|
||||||
}
|
}
|
||||||
|
|
20
commoncgi.py
20
commoncgi.py
|
@ -8,12 +8,21 @@ if os.environ.has_key('HTTP_COOKIE'):
|
||||||
cookie.load(os.environ['HTTP_COOKIE'])
|
cookie.load(os.environ['HTTP_COOKIE'])
|
||||||
|
|
||||||
if cookie.has_key('sess'):
|
if cookie.has_key('sess'):
|
||||||
cookie['sess']['max-age'] = 2592000
|
cookie['sess']['max-age'] = 2592000 * 3
|
||||||
cookie['sess']['version'] = 1
|
cookie['sess']['version'] = 1
|
||||||
if cookie.has_key('tz'):
|
if cookie.has_key('tz'):
|
||||||
cookie['tz']['max-age'] = 2592000
|
cookie['tz']['max-age'] = 2592000 * 3
|
||||||
cookie['tz']['version'] = 1
|
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):
|
def send_page(template):
|
||||||
data = sys.stdout.getvalue()
|
data = sys.stdout.getvalue()
|
||||||
|
@ -25,7 +34,10 @@ def send_page(template):
|
||||||
fd = open(template)
|
fd = open(template)
|
||||||
tmpl = fd.read()
|
tmpl = fd.read()
|
||||||
fd.close()
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
def q(txt):
|
def q(txt):
|
||||||
|
|
Loading…
Reference in New Issue