!info should work regardless of the number of spaces in the command...
This commit is contained in:
parent
75c51ddbc1
commit
c375c9757e
|
@ -38,6 +38,7 @@ import supybot.ircutils as ircutils
|
||||||
import supybot.ircdb as ircdb
|
import supybot.ircdb as ircdb
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import packages
|
import packages
|
||||||
reload(packages)
|
reload(packages)
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ def get_user(msg):
|
||||||
class PackageInfo(callbacks.Plugin):
|
class PackageInfo(callbacks.Plugin):
|
||||||
"""Lookup package information via apt-cache/apt-file"""
|
"""Lookup package information via apt-cache/apt-file"""
|
||||||
threaded = True
|
threaded = True
|
||||||
|
space_re = re.compile(r' *')
|
||||||
|
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
self.__parent = super(PackageInfo, self)
|
self.__parent = super(PackageInfo, self)
|
||||||
|
@ -155,9 +157,9 @@ class PackageInfo(callbacks.Plugin):
|
||||||
|
|
||||||
def privmsg(self, irc, msg, user):
|
def privmsg(self, irc, msg, user):
|
||||||
channel = self.__getChannel(msg.args[0])
|
channel = self.__getChannel(msg.args[0])
|
||||||
text = msg.args[1].strip()
|
text = self.space_re.subn(' ', msg.args[1].strip())[0]
|
||||||
if text[0] == self.registryValue("prefixchar"):
|
if text[0] == self.registryValue("prefixchar"):
|
||||||
text = text[1:]
|
text = text[1:].strip()
|
||||||
if user and text[0] in str(conf.supybot.reply.whenAddressedBy.get('chars')):
|
if user and text[0] in str(conf.supybot.reply.whenAddressedBy.get('chars')):
|
||||||
return
|
return
|
||||||
(cmd, rest) = (text.split(' ', 1) + [None])[:2]
|
(cmd, rest) = (text.split(' ', 1) + [None])[:2]
|
||||||
|
@ -173,10 +175,9 @@ class PackageInfo(callbacks.Plugin):
|
||||||
|
|
||||||
def chanmsg(self, irc, msg, user):
|
def chanmsg(self, irc, msg, user):
|
||||||
channel = self.__getChannel(msg.args[0])
|
channel = self.__getChannel(msg.args[0])
|
||||||
text = msg.args[1].strip()
|
text = self.space_re.subn(' ', msg.args[1].strip())[0]
|
||||||
if text[0] != self.registryValue("prefixchar", channel):
|
if text[0] != self.registryValue("prefixchar", channel):
|
||||||
return
|
return
|
||||||
text = text[1:]
|
|
||||||
(cmd, rest) = (text.split(' ', 1) + [None])[:2]
|
(cmd, rest) = (text.split(' ', 1) + [None])[:2]
|
||||||
if cmd not in ("find", "info"):
|
if cmd not in ("find", "info"):
|
||||||
return
|
return
|
||||||
|
@ -209,16 +210,26 @@ class PackageInfo(callbacks.Plugin):
|
||||||
return msg
|
return msg
|
||||||
if not conf.supybot.defaultIgnore():
|
if not conf.supybot.defaultIgnore():
|
||||||
return msg
|
return msg
|
||||||
text = msg.args[1]
|
text = msg.args[1].strip()
|
||||||
|
if len(text) < 6:
|
||||||
|
return msg
|
||||||
user = get_user(msg)
|
user = get_user(msg)
|
||||||
if user:
|
if user:
|
||||||
return msg
|
return msg
|
||||||
channel = self.__getChannel(msg.args[0])
|
channel = self.__getChannel(msg.args[0])
|
||||||
if channel:
|
if channel:
|
||||||
if not text[:5] in ("!info", "!find", "@info", "@find"):
|
if text[0] not in ('!', '@'):
|
||||||
return msg
|
return msg
|
||||||
|
if not text[1:5] in ("info", "find"):
|
||||||
|
return msg
|
||||||
|
# irc = callbacks.ReplyIrcProxy(irc, msg)
|
||||||
|
# self.doPrivmsg(irc, msg)
|
||||||
else:
|
else:
|
||||||
if text[:5] in ("info ", "find ", "!info", "!find", "@info", "@find"):
|
if text[1] in ('!', '@'):
|
||||||
|
if text[1:5] in ("info", "find"):
|
||||||
|
irc = callbacks.ReplyIrcProxy(irc, msg)
|
||||||
|
self.doPrivmsg(irc, msg)
|
||||||
|
elif text[:4] in ("info", "find"):
|
||||||
irc = callbacks.ReplyIrcProxy(irc, msg)
|
irc = callbacks.ReplyIrcProxy(irc, msg)
|
||||||
self.doPrivmsg(irc, msg)
|
self.doPrivmsg(irc, msg)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue