From 00f353f3a9ec852b2c1adfc222bb762418f7bec2 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 27 Nov 2014 21:08:48 -0800 Subject: [PATCH] NoTrigger/PkgInfo: be more verbose in logging output --- NoTrigger/plugin.py | 23 +++++++++++++++++------ PkgInfo/plugin.py | 11 ++++++++--- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/NoTrigger/plugin.py b/NoTrigger/plugin.py index 03c6ea5..6830781 100644 --- a/NoTrigger/plugin.py +++ b/NoTrigger/plugin.py @@ -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)): diff --git a/PkgInfo/plugin.py b/PkgInfo/plugin.py index d2a7fb5..fa273ae 100644 --- a/PkgInfo/plugin.py +++ b/PkgInfo/plugin.py @@ -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 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)