NoTrigger/PkgInfo: be more verbose in logging output

This commit is contained in:
James Lu 2014-11-27 21:08:48 -08:00
parent 89ee585e1f
commit 00f353f3a9
2 changed files with 25 additions and 9 deletions

View File

@ -59,25 +59,36 @@ class NoTrigger(callbacks.Plugin):
ircutils.isChannel(msg.args[0]) and \
self.registryValue('enable', msg.args[0]):
s = msg.args[1]
prefixes = list(string.punctuation)
prefixes = string.punctuation
rpairs = {"\007":""
}
suffixes = ("moo")
if self.registryValue('colorAware') and \
self.isChanStripColor(irc, msg.args[0]):
self.isChanStripColor(irc, msg.args[0]) and \
s.startswith(("\003", "\002", "\017", "\037", "\026")):
# \003 = Colour (Ctrl+K), \002 = Bold (Ctrl+B), \017 =
# Reset Formatting (Ctrl+O), \037 = Underline,
# \026 = Italic/Reverse video
prefixes += ["\003", "\002", "\017", "\037", "\026"]
if self.registryValue('spaceBeforeNicks', msg.args[0]):
self.log.info("NoTrigger (%s/%s): prepending message with "
"a space since our message begins with a formatting code "
"and the channel seems to be blocking colors." % \
(msg.args[0], irc.network))
s = " " + s
elif self.registryValue('spaceBeforeNicks', msg.args[0]) and \
s.split()[0].endswith((",", ":")):
# If the last character of the first word ends with a ',' or
# ':', prepend a space.
if s.split()[0].endswith((",", ":")):
s = " " + s
s = " " + s
self.log.info("NoTrigger (%s/%s): prepending message with "
"a space due to config plugins.notrigger."
"spaceBeforeNicks." % (msg.args[0], irc.network))
# Handle actions properly but destroy any other \001 (CTCP) messages
if self.registryValue('blockCtcp', msg.args[0]) and \
s.startswith("\001") and not s.startswith("\001ACTION"):
s = s[1:-1]
self.log.info("NoTrigger (%s/%s): blocking non-ACTION "
"CTCP due to config plugins.notrigger.blockCtcp." % \
(msg.args[0], irc.network))
for k, v in rpairs.items():
s = s.replace(k, v)
if s.startswith(tuple(prefixes)):

View File

@ -96,6 +96,7 @@ class PkgInfo(callbacks.Plugin):
self.arg['S'] = 'on'
self.arg = urlencode(self.arg)
url = 'https://qa.debian.org/madison.php?text=on&' + self.arg
self.log.debug("PkgInfo: Using url %s for 'vlist' command" % url)
d = OrderedDict()
fd = utils.web.getUrlFd(url)
for line in fd.readlines():
@ -191,9 +192,11 @@ class PkgInfo(callbacks.Plugin):
pkg = pkg.lower()
baseurl = 'https://www.archlinux.org/packages/search/json/?'
if 'exact' in dict(opts):
fd = utils.web.getUrl(baseurl + urlencode({'name':pkg}))
url = baseurl + urlencode({'name':pkg})
else:
fd = utils.web.getUrl(baseurl + urlencode({'q':pkg}))
url = baseurl + urlencode({'q':pkg})
self.log.debug("PkgInfo: using url %s for 'archpkg' command" % url)
fd = utils.web.getUrl(url)
data = json.loads(fd.decode("utf-8"))
if data['valid'] and data['results']:
f = set()
@ -217,7 +220,9 @@ class PkgInfo(callbacks.Plugin):
Looks up <package> in the Arch Linux AUR."""
pkg = pkg.lower()
baseurl = 'https://aur.archlinux.org/rpc.php?type=search&'
fd = utils.web.getUrl(baseurl + urlencode({'arg':pkg}))
url = baseurl + urlencode({'arg':pkg})
self.log.debug("PkgInfo: using url %s for 'archaur' command" % url)
fd = utils.web.getUrl(url)
data = json.loads(fd.decode("utf-8"))
if data["type"] == "error":
irc.error(data["results"], Raise=True)