This project is now officially the one with the worst commitlog :)
Fixes all over the place, won't say which :p
This commit is contained in:
@ -114,6 +114,12 @@ class Bantracker(callbacks.Plugin):
|
|||||||
if format:
|
if format:
|
||||||
s = time.strftime(format) + " " + ircutils.stripFormatting(s)
|
s = time.strftime(format) + " " + ircutils.stripFormatting(s)
|
||||||
self.logs[channel] = self.logs[channel][-199:] + [s.strip()]
|
self.logs[channel] = self.logs[channel][-199:] + [s.strip()]
|
||||||
|
|
||||||
|
def doStatsLog(self, irc, msg, type):
|
||||||
|
#format = conf.supybot.log.timestampFormat()
|
||||||
|
#print "%15s %s %s %s %s" % (msg.args[0], time.strftime(format), type,
|
||||||
|
# msg.prefix, len(irc.state.channels[msg.args[0]].users))
|
||||||
|
pass
|
||||||
|
|
||||||
def doKickban(self, irc, channel, nick, target, kickmsg = None):
|
def doKickban(self, irc, channel, nick, target, kickmsg = None):
|
||||||
if not self.registryValue('enabled', channel):
|
if not self.registryValue('enabled', channel):
|
||||||
@ -159,6 +165,7 @@ class Bantracker(callbacks.Plugin):
|
|||||||
for channel in msg.args[0].split(','):
|
for channel in msg.args[0].split(','):
|
||||||
self.doLog(irc, channel,
|
self.doLog(irc, channel,
|
||||||
'*** %s has joined %s\n' % (msg.nick or msg.prefix, channel))
|
'*** %s has joined %s\n' % (msg.nick or msg.prefix, channel))
|
||||||
|
self.doStatsLog(irc, msg, "JOIN")
|
||||||
|
|
||||||
def doKick(self, irc, msg):
|
def doKick(self, irc, msg):
|
||||||
if len(msg.args) == 3:
|
if len(msg.args) == 3:
|
||||||
@ -173,6 +180,7 @@ class Bantracker(callbacks.Plugin):
|
|||||||
self.doLog(irc, channel,
|
self.doLog(irc, channel,
|
||||||
'*** %s was kicked by %s\n' % (target, msg.nick))
|
'*** %s was kicked by %s\n' % (target, msg.nick))
|
||||||
self.doKickban(irc, channel, msg.nick, target, kickmsg)
|
self.doKickban(irc, channel, msg.nick, target, kickmsg)
|
||||||
|
self.doStatsLog(irc, msg, "KICK")
|
||||||
|
|
||||||
def doPart(self, irc, msg):
|
def doPart(self, irc, msg):
|
||||||
for channel in msg.args[0].split(','):
|
for channel in msg.args[0].split(','):
|
||||||
@ -180,6 +188,7 @@ class Bantracker(callbacks.Plugin):
|
|||||||
if msg.args[1].startswith('requested by'):
|
if msg.args[1].startswith('requested by'):
|
||||||
args = msg.args[1].split()
|
args = msg.args[1].split()
|
||||||
self.doKickban(irc, channel, args[2].replace(':',''), msg.nick, ' '.join(args[3:])[1:-1].strip())
|
self.doKickban(irc, channel, args[2].replace(':',''), msg.nick, ' '.join(args[3:])[1:-1].strip())
|
||||||
|
self.doStatsLog(irc, msg, "PART")
|
||||||
|
|
||||||
def doMode(self, irc, msg):
|
def doMode(self, irc, msg):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
@ -215,6 +224,7 @@ class Bantracker(callbacks.Plugin):
|
|||||||
for (channel, chan) in self.lastStates[irc].channels.iteritems():
|
for (channel, chan) in self.lastStates[irc].channels.iteritems():
|
||||||
if msg.nick in chan.users:
|
if msg.nick in chan.users:
|
||||||
self.doLog(irc, channel, '*** %s has quit IRC (%s)\n' % (msg.nick, msg.args[0]))
|
self.doLog(irc, channel, '*** %s has quit IRC (%s)\n' % (msg.nick, msg.args[0]))
|
||||||
|
self.doStatsLog(irc, msg, "QUIT")
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
# Gotta catch my own messages *somehow* :)
|
# Gotta catch my own messages *somehow* :)
|
||||||
|
@ -162,7 +162,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
|||||||
except:
|
except:
|
||||||
print "Unable to get bug %d" % b
|
print "Unable to get bug %d" % b
|
||||||
except:
|
except:
|
||||||
raise
|
#raise
|
||||||
pass # Ignore errors. Iz wrong mail
|
pass # Ignore errors. Iz wrong mail
|
||||||
break
|
break
|
||||||
print "New bugs in %s (%s): %s" % (c, dir, str(bugs[dir].keys()))
|
print "New bugs in %s (%s): %s" % (c, dir, str(bugs[dir].keys()))
|
||||||
@ -604,6 +604,32 @@ class Trac(IBugtracker):
|
|||||||
if 'headers="h_severity"' in l:
|
if 'headers="h_severity"' in l:
|
||||||
severity = l[l.find('>')+1:l.find('</')]
|
severity = l[l.find('>')+1:l.find('</')]
|
||||||
return (package, title, severity, status, "%s/%s" % (self.url, id))
|
return (package, title, severity, status, "%s/%s" % (self.url, id))
|
||||||
|
|
||||||
|
class WikiForms(IBugtracker):
|
||||||
|
def get_bug(self, id):
|
||||||
|
def strip_tags(s):
|
||||||
|
while '<' in s and '>' in s:
|
||||||
|
s = str(s[:s.find('<')]) + str(s[s.find('>')+1:])
|
||||||
|
return s
|
||||||
|
|
||||||
|
url = "%s/%05d" % (self.url, id)
|
||||||
|
print url
|
||||||
|
try:
|
||||||
|
bugdata = utils.web.getUrl(url)
|
||||||
|
except Exception, e:
|
||||||
|
s = 'Could not parse data returned by %s: %s' % (self.description, e)
|
||||||
|
raise BugtrackerError, s
|
||||||
|
for l in bugdata.split("\n"):
|
||||||
|
l2 = l.lower()
|
||||||
|
if '<dt>importance</dt>' in l2:
|
||||||
|
severity = 'Importance ' + strip_tags(l[l.find('<dd>')+4:])
|
||||||
|
if '<dt>summary</dt>' in l2:
|
||||||
|
title = strip_tags(l[l.find('<dd>')+4:])
|
||||||
|
if '<dt>status</dt>' in l2:
|
||||||
|
status = strip_tags(l[l.find('<dd>')+4:])
|
||||||
|
if '<dt>category</dt>' in l2:
|
||||||
|
package = strip_tags(l[l.find('<dd>')+4:])
|
||||||
|
return (package, title, severity, status, "%s/%05d" % (self.url, id))
|
||||||
|
|
||||||
sfre = re.compile(r"""
|
sfre = re.compile(r"""
|
||||||
.*?
|
.*?
|
||||||
|
@ -33,6 +33,8 @@ conf.registerGlobalValue(Encyclopedia, 'relaychannel',
|
|||||||
registry.String('#ubuntu-ops', 'Relay channel for unauthorized edits'))
|
registry.String('#ubuntu-ops', 'Relay channel for unauthorized edits'))
|
||||||
conf.registerGlobalValue(Encyclopedia, 'notfoundmsg',
|
conf.registerGlobalValue(Encyclopedia, 'notfoundmsg',
|
||||||
registry.String('Factoid %s not found', 'Reply when factoid isn\'t found'))
|
registry.String('Factoid %s not found', 'Reply when factoid isn\'t found'))
|
||||||
|
conf.registerChannelValue(Encyclopedia, 'searchorder',
|
||||||
|
registry.String('','Distro search order'))
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||||
|
@ -20,10 +20,7 @@ apt_pkg.init()
|
|||||||
|
|
||||||
datadir = '/home/dennis/ubugtu/data/facts'
|
datadir = '/home/dennis/ubugtu/data/facts'
|
||||||
aptdir = '/home/dennis/ubugtu/data/apt'
|
aptdir = '/home/dennis/ubugtu/data/apt'
|
||||||
distros = ('dapper','breezy','edgy','hoary','warty','dapper-commercial','dapper-seveas','breezy-seveas','dapper-imbrandon','edgy-imbrandon', 'dapper-backports')
|
distros = ('dapper','breezy','edgy','hoary','warty','dapper-commercial','dapper-seveas','breezy-seveas','dapper-imbrandon','edgy-imbrandon', 'dapper-backports','edgy-seveas')
|
||||||
defaultdistro = 'dapper'
|
|
||||||
# Keep 'searchistros' in search order!
|
|
||||||
searchdistros = ('dapper','dapper-commercial','dapper-seveas','dapper-imbrandon')
|
|
||||||
|
|
||||||
# Simple wrapper class for factoids
|
# Simple wrapper class for factoids
|
||||||
class Factoid:
|
class Factoid:
|
||||||
@ -39,6 +36,7 @@ class FactoidSet:
|
|||||||
|
|
||||||
msgcache = {}
|
msgcache = {}
|
||||||
def queue(irc, to, msg):
|
def queue(irc, to, msg):
|
||||||
|
print "Message to %s: %s" % (to, msg)
|
||||||
now = time.time()
|
now = time.time()
|
||||||
for m in msgcache.keys():
|
for m in msgcache.keys():
|
||||||
if msgcache[m] < now - 30:
|
if msgcache[m] < now - 30:
|
||||||
@ -83,6 +81,11 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
irc.reply(', '.join([ircdb.users.getUser(u).name for u in ircdb.users.users \
|
irc.reply(', '.join([ircdb.users.getUser(u).name for u in ircdb.users.users \
|
||||||
if 'editfactoids' in ircdb.users.getUser(u).capabilities]))
|
if 'editfactoids' in ircdb.users.getUser(u).capabilities]))
|
||||||
editors = wrap(editors)
|
editors = wrap(editors)
|
||||||
|
|
||||||
|
def _checkdists(self, channel):
|
||||||
|
cd = self.registryValue('searchorder', channel=channel)
|
||||||
|
print cd
|
||||||
|
return cd.split()
|
||||||
|
|
||||||
def moderators(self, irc, msg, args):
|
def moderators(self, irc, msg, args):
|
||||||
irc.reply(', '.join([ircdb.users.getUser(u).name for u in ircdb.users.users \
|
irc.reply(', '.join([ircdb.users.getUser(u).name for u in ircdb.users.users \
|
||||||
@ -103,6 +106,8 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
self.seens.pop(n)
|
self.seens.pop(n)
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
|
if chr(1) in msg.args[1]:
|
||||||
|
return
|
||||||
recipient, text = msg.args
|
recipient, text = msg.args
|
||||||
text = addressed(recipient, text, irc)
|
text = addressed(recipient, text, irc)
|
||||||
if not text:
|
if not text:
|
||||||
@ -127,10 +132,10 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
text = text.lower()
|
text = text.lower()
|
||||||
if self.registryValue('packagelookup'):
|
if self.registryValue('packagelookup'):
|
||||||
if text.startswith('info '):
|
if text.startswith('info '):
|
||||||
queue(irc, target, pkginfo(text[5:].strip()))
|
queue(irc, target, pkginfo(text[5:].strip(),self._checkdists(msg.args[0])))
|
||||||
return
|
return
|
||||||
if text.startswith('find '):
|
if text.startswith('find '):
|
||||||
queue(irc, target, findpkg(text[5:].strip()))
|
queue(irc, target, findpkg(text[5:].strip(),self._checkdists(msg.args[0])))
|
||||||
return
|
return
|
||||||
if text.startswith('seen '):
|
if text.startswith('seen '):
|
||||||
self.seens[text[5:].strip()] = (target, time.time())
|
self.seens[text[5:].strip()] = (target, time.time())
|
||||||
@ -162,7 +167,7 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
text = text.replace('is<sed>','=~',1)
|
text = text.replace('is<sed>','=~',1)
|
||||||
elif ' is <sed>' in text:
|
elif ' is <sed>' in text:
|
||||||
text = text.replace('is <sed>','=~',1)
|
text = text.replace('is <sed>','=~',1)
|
||||||
if ' is ' in text and '=~' not in text:
|
if ' is ' in text and '=~' not in text and not ('|' in text and text.find(' is ') > text.find('|')):
|
||||||
do_new = True
|
do_new = True
|
||||||
if text.lower()[:3] in ('no ','no,'):
|
if text.lower()[:3] in ('no ','no,'):
|
||||||
do_new = False
|
do_new = False
|
||||||
@ -180,7 +185,6 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
irc.error('Internal error, please report')
|
irc.error('Internal error, please report')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Big action 1: editing factoids
|
# Big action 1: editing factoids
|
||||||
if '=~' in text:
|
if '=~' in text:
|
||||||
# Editing
|
# Editing
|
||||||
@ -263,8 +267,14 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
# Check resolving of aliases
|
# Check resolving of aliases
|
||||||
if f.value.startswith('<alias>'):
|
if f.value.startswith('<alias>'):
|
||||||
alias = f.value[7:].strip()
|
alias = f.value[7:].strip()
|
||||||
|
if name == alias:
|
||||||
|
irc.error("Recursive <alias> detected. Bailing out!")
|
||||||
|
return
|
||||||
aliases = get_factoids(db, alias, newchannel, resolve=True)
|
aliases = get_factoids(db, alias, newchannel, resolve=True)
|
||||||
if aliases.global_primary:
|
if aliases.global_primary:
|
||||||
|
if name == aliases.global_primary.name:
|
||||||
|
irc.error("Recursive <alias> detected. Bailing out!")
|
||||||
|
return
|
||||||
f.value = '<alias> ' + aliases.global_primary.name
|
f.value = '<alias> ' + aliases.global_primary.name
|
||||||
elif aliases.channel_primary:
|
elif aliases.channel_primary:
|
||||||
f.name += '-%s' % newchannel
|
f.name += '-%s' % newchannel
|
||||||
@ -289,10 +299,13 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
if ' tell ' in text and ' about ' in text:
|
if ' tell ' in text and ' about ' in text:
|
||||||
_target = text[text.find(' tell ')+6:].strip().split(None,1)[0]
|
_target = text[text.find(' tell ')+6:].strip().split(None,1)[0]
|
||||||
text = text[text.find(' about ')+7:].strip()
|
text = text[text.find(' about ')+7:].strip()
|
||||||
|
if '|' in text:
|
||||||
|
retmsg = text[text.find('|')+1:].strip() + ': '
|
||||||
|
text = text[:text.find('|')].strip()
|
||||||
if _target:
|
if _target:
|
||||||
# Validate
|
# Validate
|
||||||
if _target == 'me':
|
if _target == 'me':
|
||||||
target = msg.nick
|
_target = msg.nick
|
||||||
for chan in irc.state.channels:
|
for chan in irc.state.channels:
|
||||||
if _target in irc.state.channels[chan].users and msg.nick in irc.state.channels[chan].users:
|
if _target in irc.state.channels[chan].users and msg.nick in irc.state.channels[chan].users:
|
||||||
target = _target
|
target = _target
|
||||||
@ -303,6 +316,8 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
return
|
return
|
||||||
factoids = get_factoids(db, text.lower(), channel, resolve = not display_info, info = display_info)
|
factoids = get_factoids(db, text.lower(), channel, resolve = not display_info, info = display_info)
|
||||||
replied = False
|
replied = False
|
||||||
|
if target.lower() == msg.nick.lower() and msg.args[0][0] == '#':
|
||||||
|
queue(irc, target, "To send answers to yourself, please use /msg instead of spamming the channel")
|
||||||
for key in ('channel_primary', 'global_primary'):
|
for key in ('channel_primary', 'global_primary'):
|
||||||
if getattr(factoids, key):
|
if getattr(factoids, key):
|
||||||
replied = True
|
replied = True
|
||||||
@ -322,7 +337,7 @@ class Encyclopedia(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
if not replied:
|
if not replied:
|
||||||
if self.registryValue('packagelookup'):
|
if self.registryValue('packagelookup'):
|
||||||
i = pkginfo(text)
|
i = pkginfo(text,self._checkdists(msg.args[0]))
|
||||||
if not i.startswith('Package'):
|
if not i.startswith('Package'):
|
||||||
queue(irc, target, i)
|
queue(irc, target, i)
|
||||||
else:
|
else:
|
||||||
@ -353,12 +368,12 @@ def addressed(recipients, text, irc):
|
|||||||
text = text.strip()
|
text = text.strip()
|
||||||
if text[0] == '!':
|
if text[0] == '!':
|
||||||
text = text[1:]
|
text = text[1:]
|
||||||
if text.lower().startswith('ubotu'):
|
if text.lower().startswith('ubotu') and (len(text) < 5 or not text[5].isalnum()):
|
||||||
t2 = text[5:].strip()
|
t2 = text[5:].strip()
|
||||||
if t2 and t2.find('>') != 0:
|
if t2 and t2.find('>') != 0 and t2.find('|') != 0:
|
||||||
text = text[5:].strip()
|
text = text[5:].strip()
|
||||||
return text
|
return text
|
||||||
if text.lower().startswith('ubotu'): # FIXME: use nickname variable
|
if text.lower().startswith('ubotu') and not text[5].isalnum(): # FIXME: use nickname variable
|
||||||
return text[5:]
|
return text[5:]
|
||||||
return False
|
return False
|
||||||
else: # Private messages
|
else: # Private messages
|
||||||
@ -381,13 +396,13 @@ aptcommand = """apt-cache\\
|
|||||||
-o"Dir::Cache=%s/cache"\\
|
-o"Dir::Cache=%s/cache"\\
|
||||||
%%s %%s""" % tuple([aptdir]*4)
|
%%s %%s""" % tuple([aptdir]*4)
|
||||||
aptfilecommand = """apt-file -s %s/%%s.list -c %s/apt-file/%%s -l -F search %%s""" % tuple([aptdir]*2)
|
aptfilecommand = """apt-file -s %s/%%s.list -c %s/apt-file/%%s -l -F search %%s""" % tuple([aptdir]*2)
|
||||||
def findpkg(pkg,filelookup=True):
|
def findpkg(pkg,checkdists,filelookup=True):
|
||||||
_pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum or x in '.-'])
|
_pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum or x in '.-'])
|
||||||
distro = defaultdistro
|
distro = checkdists[0]
|
||||||
if len(pkg.strip().split()) > 1:
|
if len(pkg.strip().split()) > 1:
|
||||||
distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum or x in '.-'])
|
distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum or x in '.-'])
|
||||||
if distro not in distros:
|
if distro not in distros:
|
||||||
distro = defaultdistro
|
distro = checkdists[0]
|
||||||
pkg = _pkg
|
pkg = _pkg
|
||||||
|
|
||||||
data = commands.getoutput(aptcommand % (distro, distro, distro, 'search -n', pkg))
|
data = commands.getoutput(aptcommand % (distro, distro, distro, 'search -n', pkg))
|
||||||
@ -407,18 +422,19 @@ def findpkg(pkg,filelookup=True):
|
|||||||
else:
|
else:
|
||||||
return "Found: %s" % ', '.join(pkgs[:5])
|
return "Found: %s" % ', '.join(pkgs[:5])
|
||||||
|
|
||||||
def pkginfo(pkg):
|
def pkginfo(pkg,checkdists):
|
||||||
|
print pkg, checkdists
|
||||||
_pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum() or x in '.-'])
|
_pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum() or x in '.-'])
|
||||||
distro = None
|
distro = None
|
||||||
if len(pkg.strip().split()) > 1:
|
if len(pkg.strip().split()) > 1:
|
||||||
distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum() or x in '-.'])
|
distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum() or x in '-.'])
|
||||||
if not distro:
|
if distro:
|
||||||
checkdists = searchdistros
|
if distro not in distros:
|
||||||
elif distro not in distros:
|
checkdists = [checkdists[0]]
|
||||||
checkdists = [defaultdistro]
|
else:
|
||||||
else:
|
checkdists = [distro]
|
||||||
checkdists = [distro]
|
|
||||||
pkg = _pkg
|
pkg = _pkg
|
||||||
|
print pkg, checkdists
|
||||||
|
|
||||||
for distro in checkdists:
|
for distro in checkdists:
|
||||||
data = commands.getoutput(aptcommand % (distro, distro, distro, 'show', pkg))
|
data = commands.getoutput(aptcommand % (distro, distro, distro, 'show', pkg))
|
||||||
@ -433,6 +449,7 @@ def pkginfo(pkg):
|
|||||||
parser = FeedParser.FeedParser()
|
parser = FeedParser.FeedParser()
|
||||||
parser.feed(p)
|
parser.feed(p)
|
||||||
p = parser.close()
|
p = parser.close()
|
||||||
|
print p, p['Version']
|
||||||
if apt_pkg.VersionCompare(maxp['Version'], p['Version']) < 0:
|
if apt_pkg.VersionCompare(maxp['Version'], p['Version']) < 0:
|
||||||
maxp = p
|
maxp = p
|
||||||
del parser
|
del parser
|
||||||
|
Reference in New Issue
Block a user