Make 'ubotu, tell foo about bar' work again
This commit is contained in:
@ -79,7 +79,7 @@ class Encyclopedia(callbacks.PluginRegexp):
|
|||||||
inchannel = channel.startswith('#')
|
inchannel = channel.startswith('#')
|
||||||
excl = msg.args[1].startswith('!')
|
excl = msg.args[1].startswith('!')
|
||||||
wn = msg.args[1].startswith('ubotu')
|
wn = msg.args[1].startswith('ubotu')
|
||||||
if inchannel and not (excl or (wn and withnick)):
|
if inchannel and not (excl or (withnick and wn)):
|
||||||
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]
|
||||||
@ -141,7 +141,7 @@ 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+).*)?$"
|
||||||
withnick = bool(match.group(1)) and msg.args[1].startswith('ubotu')
|
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')))
|
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
|
||||||
@ -183,11 +183,11 @@ class Encyclopedia(callbacks.PluginRegexp):
|
|||||||
try:
|
try:
|
||||||
factoid = get_factoid(db, factoid, channel)
|
factoid = get_factoid(db, factoid, channel)
|
||||||
if not factoid:
|
if not factoid:
|
||||||
irc.reply('I know nothing about %s' % match.group('factoid'))
|
irc.reply('I know nothing about %s - try searching bots.ubuntulinux.nl, help.ubuntu.com and wiki.ubuntu.com' % match.group('factoid'))
|
||||||
return
|
return
|
||||||
# Output factoid
|
# Output factoid
|
||||||
if noalias:
|
if noalias:
|
||||||
if not self._precheck(irc, msg, timeout=(to,factoid.name,1)):
|
if not self._precheck(irc, msg, timeout=(to,factoid.name,1),withnick=True):
|
||||||
return
|
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()
|
||||||
@ -204,7 +204,7 @@ class Encyclopedia(callbacks.PluginRegexp):
|
|||||||
else:
|
else:
|
||||||
factoid = resolve_alias(db,factoid,channel)
|
factoid = resolve_alias(db,factoid,channel)
|
||||||
# Do timing
|
# Do timing
|
||||||
if not self._precheck(irc, msg, timeout=(to,factoid.name)):
|
if not self._precheck(irc, msg, timeout=(to,factoid.name,2),withnick=True):
|
||||||
return
|
return
|
||||||
cur.execute("UPDATE FACTS SET popularity = %d WHERE name = %s", factoid.popularity+1, factoid.name)
|
cur.execute("UPDATE FACTS SET popularity = %d WHERE name = %s", factoid.popularity+1, factoid.name)
|
||||||
db.commit()
|
db.commit()
|
||||||
@ -404,7 +404,6 @@ class Encyclopedia(callbacks.PluginRegexp):
|
|||||||
if (match.group('distro') in ('warty','hoary','breezy','dapper','edgy','breezy-seveas','dapper-seveas')):
|
if (match.group('distro') in ('warty','hoary','breezy','dapper','edgy','breezy-seveas','dapper-seveas')):
|
||||||
distro = match.group('distro')
|
distro = match.group('distro')
|
||||||
data = commands.getoutput(self.aptcommand % (distro, distro, distro, 'show', match.group('package')))
|
data = commands.getoutput(self.aptcommand % (distro, distro, distro, 'show', match.group('package')))
|
||||||
print data
|
|
||||||
if not data or 'E: No packages found' in data:
|
if not data or 'E: No packages found' in data:
|
||||||
irc.reply('Package %s does not exist in %s' % (match.group('package'), distro))
|
irc.reply('Package %s does not exist in %s' % (match.group('package'), distro))
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user