From 1c03464fd9ccc662de438617c38cac5eca9e23e0 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 8 Jan 2004 23:03:48 +0000 Subject: [PATCH] Huge commit to finish refactoring of replies. --- plugins/Amazon.py | 14 +++++++------- plugins/Babelfish.py | 12 ++++++------ plugins/Bugzilla.py | 5 +++-- plugins/ChannelDB.py | 6 +++--- plugins/ChannelLogger.py | 6 +++--- plugins/DCC.py | 2 +- plugins/Debian.py | 6 +++--- plugins/Dict.py | 2 +- plugins/Ebay.py | 32 ++++++++++++++++---------------- plugins/Enforcer.py | 8 ++++---- plugins/Factoids.py | 8 ++++---- plugins/Filter.py | 2 +- plugins/Fun.py | 2 +- plugins/FunDB.py | 8 +++----- plugins/Gameknot.py | 16 ++++++++-------- plugins/Google.py | 21 ++++++++++----------- plugins/Http.py | 16 ++++++++-------- plugins/Karma.py | 4 ---- plugins/Lookup.py | 2 +- plugins/Poll.py | 4 ++-- plugins/Quotes.py | 9 +++++---- plugins/Relay.py | 2 +- plugins/Scheduler.py | 4 ++-- plugins/Services.py | 2 +- plugins/Sourceforge.py | 29 ++++++++++++++--------------- plugins/Todo.py | 8 ++++---- plugins/URL.py | 7 +++---- plugins/Unix.py | 6 +++--- plugins/Weather.py | 36 +++++++++++++++++------------------- plugins/Words.py | 2 +- src/Admin.py | 2 +- src/Owner.py | 4 ++-- src/User.py | 2 +- src/callbacks.py | 8 +++++--- src/ircdb.py | 8 ++++---- 35 files changed, 149 insertions(+), 156 deletions(-) diff --git a/plugins/Amazon.py b/plugins/Amazon.py index 9b3486428..c209a1a53 100644 --- a/plugins/Amazon.py +++ b/plugins/Amazon.py @@ -136,7 +136,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin): 'Authors' : 'author', 'URL' : 'url' } - s = '"%(title)s", written by %(author)s; published by '\ + s = '"%(title)s", written by %(author)s; published by ' \ '%(publisher)s%(url)s' try: book = amazon.searchByKeyword(isbn) @@ -169,7 +169,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin): 'Authors' : 'author', 'URL' : 'url' } - s = '"%(title)s", written by %(author)s; published by '\ + s = '"%(title)s", written by %(author)s; published by ' \ '%(publisher)s%(url)s' try: books = amazon.searchByKeyword(keyword) @@ -208,7 +208,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin): 'ReleaseDate' : 'date', 'URL' : 'url' } - s = '"%(title)s" (%(media)s), rated %(mpaa)s; released '\ + s = '"%(title)s" (%(media)s), rated %(mpaa)s; released ' \ '%(date)s; published by %(publisher)s%(url)s' try: videos = amazon.searchByKeyword(keyword, product_line=product) @@ -306,7 +306,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin): 'Authors' : 'author', 'URL' : 'url' } - s = '"%(title)s", written by %(author)s; published by '\ + s = '"%(title)s", written by %(author)s; published by ' \ '%(publisher)s%(url)s' try: books = amazon.searchByAuthor(author) @@ -404,7 +404,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin): 'Media' : 'media', 'URL' : 'url' } - s = '"%(title)s" (%(media)s), by %(artist)s; published by '\ + s = '"%(title)s" (%(media)s), by %(artist)s; published by ' \ '%(publisher)s%(url)s' try: items = amazon.searchByArtist(artist, product_line=product) @@ -444,7 +444,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin): 'ReleaseDate' : 'date', 'URL' : 'url' } - s = '"%(title)s" (%(media)s), rated %(mpaa)s; released '\ + s = '"%(title)s" (%(media)s), rated %(mpaa)s; released ' \ '%(date)s; published by %(publisher)s%(url)s' try: items = amazon.searchByActor(actor, product_line=product) @@ -484,7 +484,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin): 'ReleaseDate' : 'date', 'URL' : 'url' } - s = '"%(title)s" (%(media)s), rated %(mpaa)s; released '\ + s = '"%(title)s" (%(media)s), rated %(mpaa)s; released ' \ '%(date)s; published by %(publisher)s%(url)s' try: items = amazon.searchByDirector(director, product_line=product) diff --git a/plugins/Babelfish.py b/plugins/Babelfish.py index 0a993a75e..65e77d0a3 100644 --- a/plugins/Babelfish.py +++ b/plugins/Babelfish.py @@ -79,13 +79,13 @@ class Babelfish(callbacks.Privmsg): translation = babelfish.translate(text, fromLang, toLang) irc.reply(translation) except (KeyError, babelfish.LanguageNotAvailableError), e: - irc.error('%s is not a valid language. Valid languages ' \ - 'include %s' % \ + irc.error('%s is not a valid language. Valid languages ' + 'include %s' % (e, utils.commaAndify(babelfish.available_languages))) except babelfish.BabelizerIOError, e: irc.error(e) except babelfish.BabelfishChangedError, e: - irc.error('Babelfish has foiled our plans by changing its ' \ + irc.error('Babelfish has foiled our plans by changing its ' 'webpage format') def babelize(self, irc, msg, args): @@ -105,13 +105,13 @@ class Babelfish(callbacks.Privmsg): translations = babelfish.babelize(text, fromLang, toLang) irc.reply(translations[-1]) except (KeyError, babelfish.LanguageNotAvailableError), e: - irc.reply('%s is not a valid language. Valid languages ' \ - 'include %s' % \ + irc.reply('%s is not a valid language. Valid languages ' + 'include %s' % (e, utils.commaAndify(babelfish.available_languages))) except babelfish.BabelizerIOError, e: irc.reply(e) except babelfish.BabelfishChangedError, e: - irc.reply('Babelfish has foiled our plans by changing its ' \ + irc.reply('Babelfish has foiled our plans by changing its ' 'webpage format') def randomlanguage(self, irc, msg, args): diff --git a/plugins/Bugzilla.py b/plugins/Bugzilla.py index 5051417ac..2ec99b816 100644 --- a/plugins/Bugzilla.py +++ b/plugins/Bugzilla.py @@ -198,8 +198,9 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): return queryurl = '%s/xml.cgi?id=%s' % (match.group(1), match.group(2)) try: - summary = self._get_short_bug_summary(queryurl, 'Snarfed '\ - 'Bugzilla URL', match.group(2)) + summary = self._get_short_bug_summary(queryurl, + 'Snarfed Bugzilla URL', + match.group(2)) except BugzillaError, e: irc.reply(str(e)) return diff --git a/plugins/ChannelDB.py b/plugins/ChannelDB.py index 17925b79f..158a92253 100644 --- a/plugins/ChannelDB.py +++ b/plugins/ChannelDB.py @@ -452,7 +452,7 @@ class ChannelDB(plugins.ChannelDBHandler, values = cursor.fetchone() s = '%s has sent %s; a total of %s, %s, ' \ '%s, and %s; %s of those messages %s' \ - '%s has joined %s, parted %s, quit %s, kicked someone %s, '\ + '%s has joined %s, parted %s, quit %s, kicked someone %s, ' \ 'been kicked %s, changed the topic %s, ' \ 'and changed the mode %s.' % \ (name, utils.nItems('message', values.msgs), @@ -589,7 +589,7 @@ class ChannelDB(plugins.ChannelDBHandler, username = ircdb.users.getUser(id).name irc.error('%r has no wordstats' % username) return - L = [('%r: %s' % (word, count)) for \ + L = [('%r: %s' % (word, count)) for (word, count) in cursor.fetchall()] irc.reply(utils.commaAndify(L)) return @@ -619,7 +619,7 @@ class ChannelDB(plugins.ChannelDBHandler, ers = '%rer' % word ret = 'Top %s ' % utils.nItems(ers, numResultsShown) ret += '(out of a total of %s seen):' % \ - utils.nItems(repr(word), total) + utils.nItems(repr(word), total) L = [] for (count, id) in results[:numResultsShown]: username = ircdb.users.getUser(id).name diff --git a/plugins/ChannelLogger.py b/plugins/ChannelLogger.py index a1bdc2bfa..18cf3b1ef 100644 --- a/plugins/ChannelLogger.py +++ b/plugins/ChannelLogger.py @@ -126,7 +126,7 @@ class ChannelLogger(irclib.IrcCallback): for channel in msg.args[0].split(','): log = self.getLog(channel) self.timestamp(log) - log.write('*** %s has joined %s\n' %\ + log.write('*** %s has joined %s\n' % (msg.nick or msg.prefix, channel)) def doKick(self, irc, msg): @@ -138,7 +138,7 @@ class ChannelLogger(irclib.IrcCallback): log = self.getLog(channel) self.timestamp(log) if kickmsg: - log.write('*** %s was kicked by %s (%s)\n' % \ + log.write('*** %s was kicked by %s (%s)\n' % (target, msg.nick, kickmsg)) else: log.write('*** %s was kicked by %s\n' % (target, msg.nick)) @@ -154,7 +154,7 @@ class ChannelLogger(irclib.IrcCallback): if ircutils.isChannel(channel): log = self.getLog(channel) self.timestamp(log) - log.write('*** %s sets mode: %s %s\n' % \ + log.write('*** %s sets mode: %s %s\n' % (msg.nick or msg.prefix, msg.args[1], ' '.join(msg.args[2:]))) diff --git a/plugins/DCC.py b/plugins/DCC.py index 438b28116..70b06313a 100644 --- a/plugins/DCC.py +++ b/plugins/DCC.py @@ -80,7 +80,7 @@ class DCC(callbacks.Privmsg): s = 'Error trying to determine the external IP ' \ 'address of this machine via the host %s: %s' self.log.warning(s, host, e) - irc.reply(conf.replyError) + irc.replyError() return i = ircutils.dccIP(ip) sock.bind((host, 0)) diff --git a/plugins/Debian.py b/plugins/Debian.py index 9dd629686..da99f1d9b 100644 --- a/plugins/Debian.py +++ b/plugins/Debian.py @@ -230,8 +230,8 @@ class Debian(callbacks.Privmsg, numberOfPackages = m.group(1) m = self._debtablere.search(html) if m is None: - irc.reply('No package found for %s (%s)' % \ - (urllib.unquote(package), branch)) + irc.reply('No package found for %s (%s)' % + (urllib.unquote(package), branch)) else: tableData = m.group(1) rows = tableData.split('') @@ -242,7 +242,7 @@ class Debian(callbacks.Privmsg, s = '%s (%s)' % (pkgMatch.group(1), brMatch.group(1)) responses.append(s) resp = 'Total matches: %s, shown: %s. %s' % \ - (numberOfPackages, len(responses), ', '.join(responses)) + (numberOfPackages, len(responses), ', '.join(responses)) irc.reply(resp) _incomingRe = re.compile(r'', re.I) diff --git a/plugins/Dict.py b/plugins/Dict.py index f28d85f51..2994e4a84 100644 --- a/plugins/Dict.py +++ b/plugins/Dict.py @@ -129,7 +129,7 @@ class Dict(callbacks.Privmsg, configurable.Mixin): if dictionary == '*': irc.reply('No definition for %r could be found.' % word) else: - irc.reply('No definition for %r could be found in %s' % \ + irc.reply('No definition for %r could be found in %s' % (word, ircutils.bold(dictionary))) return L = [] diff --git a/plugins/Ebay.py b/plugins/Ebay.py index 097dca761..e292b312a 100644 --- a/plugins/Ebay.py +++ b/plugins/Ebay.py @@ -89,25 +89,25 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): callbacks.PrivmsgCommandAndRegexp.die(self) _reopts = re.I | re.S - _invalid = re.compile(r'(is invalid, still pending, or no longer in our '\ - 'database)', _reopts) + _invalid = re.compile(r'(is invalid, still pending, or no longer in our ' + r'database)', _reopts) _info = re.compile(r'eBay item (\d+) \([^)]+\) - ([^<]+)', - _reopts) + _reopts) - _bid = re.compile(r'((?:Current|Starting) bid):.+?([^<]+?)([^<]+?)([^<]+?)([^<]+?)', _reopts) - _bidder = re.compile(r'(High bidder):.+?(?:">(User ID) (kept private)'\ - '|]+>([^<]+).+?]+>(\d+))', _reopts) - _winningBidder = re.compile(r'(Winning bidder|Buyer):.+?]+>'\ - '([^<]+).+?]+>(\d+)', _reopts) + _bidder = re.compile(r'(High bidder):.+?(?:">(User ID) (kept private)' + r'|]+>([^<]+).+?' + r']+>(\d+))', _reopts) + _winningBidder = re.compile(r'(Winning bidder|Buyer):.+?]+>' + r'([^<]+).+?]+>(\d+)',_reopts) _buyNow = re.compile(r'alt="(Buy It Now)">.*?([^<]+)', _reopts) - _seller = re.compile(r'(Seller information).+?]+>([^<]+)'\ - '.+ViewFeedback.+">(\d+)', _reopts) - _searches = (_bid, _winningBid, _time, _bidder, _winningBidder, _buyNow, - _seller) + _seller = re.compile(r'(Seller information).+?]+>([^<]+)' + r'.+ViewFeedback.+">(\d+)', _reopts) + _searches = (_bid, _winningBid, _time, _bidder, + _winningBidder, _buyNow, _seller) _multiField = (_bidder, _winningBidder, _seller) def auction(self, irc, msg, args): @@ -139,8 +139,6 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): ebaySnarfer = privmsgs.urlSnarfer(ebaySnarfer) def _getResponse(self, url): - def bold(m): - return (ircutils.bold(m[0]),) + m[1:] try: fd = urllib2.urlopen(url) s = fd.read() @@ -157,6 +155,8 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): resp.append('%s%s: %s' % (ircutils.bold('Item #'), ircutils.bold(num), utils.htmlToText(desc))) + def bold(L): + return (ircutils.bold(L[0]),) + L[1:] for r in self._searches: m = r.search(s) if m: diff --git a/plugins/Enforcer.py b/plugins/Enforcer.py index ca25b035d..dcbf8580c 100644 --- a/plugins/Enforcer.py +++ b/plugins/Enforcer.py @@ -134,8 +134,8 @@ class Enforcer(callbacks.Privmsg, configurable.Mixin): irc.queueMsg(ircmsgs.topic(channel, self.topics[channel])) if self.configurables.get('revenge', channel): irc.queueMsg(ircmsgs.kick(channel, msg.nick, - conf.replyNoCapability % \ - _chanCap(channel, 'topic'))) + conf.replyNoCapability % + _chanCap(channel, 'topic'))) else: self.topics[channel] = msg.args[1] @@ -162,7 +162,7 @@ class Enforcer(callbacks.Privmsg, configurable.Mixin): channel = msg.args[0] kicked = msg.args[1].split(',') deop = False - if msg.nick != irc.nick and\ + if msg.nick != irc.nick and \ not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')): for nick in kicked: hostmask = irc.state.nickToHostmask(nick) @@ -187,7 +187,7 @@ class Enforcer(callbacks.Privmsg, configurable.Mixin): channel = msg.args[0] if not ircutils.isChannel(channel) or msg.nick == self.chanserv: return - if msg.nick != irc.nick and\ + if msg.nick != irc.nick and \ not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')): for (mode, value) in ircutils.separateModes(msg.args[1:]): if value == msg.nick: diff --git a/plugins/Factoids.py b/plugins/Factoids.py index 1aa146972..b2666c032 100644 --- a/plugins/Factoids.py +++ b/plugins/Factoids.py @@ -268,10 +268,10 @@ class Factoids(plugins.ChannelDBHandler, db.commit() irc.replySuccess() else: - irc.error('%s factoids have that key. ' \ - 'Please specify which one to remove, ' \ - 'or use * to designate all of them.' % \ - cursor.rowcount) + irc.error('%s factoids have that key. ' + 'Please specify which one to remove, ' + 'or use * to designate all of them.' % + cursor.rowcount) def random(self, irc, msg, args): """[] diff --git a/plugins/Filter.py b/plugins/Filter.py index a40ab0d7e..7a93f6884 100644 --- a/plugins/Filter.py +++ b/plugins/Filter.py @@ -203,7 +203,7 @@ class Filter(callbacks.Privmsg): s = s.translate(self._leettrans) irc.reply(s) - _scrambleRe = re.compile(r'(?:\b|(?![a-zA-Z]))([a-zA-Z])([a-zA-Z]*)'\ + _scrambleRe = re.compile(r'(?:\b|(?![a-zA-Z]))([a-zA-Z])([a-zA-Z]*)' r'([a-zA-Z])(?:\b|(?![a-zA-Z]))') def scramble(self, irc, msg, args): """ diff --git a/plugins/Fun.py b/plugins/Fun.py index 4599e4ae0..e95fd65fc 100644 --- a/plugins/Fun.py +++ b/plugins/Fun.py @@ -286,7 +286,7 @@ class Fun(callbacks.Privmsg): response = 'I have %s objects: %s modules, %s classes, %s functions, '\ '%s dictionaries, %s lists, %s tuples, %s strings, and a ' \ 'few other odds and ends. ' \ - 'I have a total of %s references.' %\ + 'I have a total of %s references.' % \ (len(objs), modules, classes, functions, dicts, lists, tuples, strings, refcounts) irc.reply(response) diff --git a/plugins/FunDB.py b/plugins/FunDB.py index 005eddcbb..4e929c69f 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -142,8 +142,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler): return if table == "lart" or table == "praise": if '$who' not in s: - irc.error('There must be a $who in the lart/praise '\ - 'somewhere.') + irc.error('There must be a $who in the lart/praise somewhere') return elif table not in self._tables: irc.error('"%s" is not valid. Valid values include %s.' % @@ -157,8 +156,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler): sql = """SELECT id FROM %ss WHERE %s=%%s""" % (table, table) cursor.execute(sql, s) id = cursor.fetchone()[0] - response = '%s (%s #%s)' % (conf.replySuccess, table, id) - irc.reply(response) + irc.replySuccess('(%s #%s)' % (table, id)) def remove(self, irc, msg, args): """[] @@ -500,7 +498,7 @@ Class = FunDB if __name__ == '__main__': import sys if len(sys.argv) < 3 or len(sys.argv) > 4: - print 'Usage: %s file'\ + print 'Usage: %s file' \ ' []' % sys.argv[0] sys.exit(-1) if len(sys.argv) == 4: diff --git a/plugins/Gameknot.py b/plugins/Gameknot.py index ad0f92c6e..6fbca7ffb 100644 --- a/plugins/Gameknot.py +++ b/plugins/Gameknot.py @@ -62,10 +62,10 @@ def configure(onStart, afterConnect, advanced): print 'that match a specific pattern (we call this a snarfer). When' print 'supybot sees such a URL, he will parse the web page for' print 'information and reply with the results.\n' - if yn('Do you want the Gameknot stats snarfer enabled by default?') ==\ + if yn('Do you want the Gameknot stats snarfer enabled by default?')==\ 'n': onStart.append('Gameknot toggle stat off') - if yn('Do you want the Gameknot Game links snarfer enabled by '\ + if yn('Do you want the Gameknot Game links snarfer enabled by ' 'default?') == 'n': onStart.append('Gameknot toggle stat off') @@ -85,8 +85,8 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): ) _gkrating = re.compile(r'(\d+)') _gkgames = re.compile(r's:(\d+)') - _gkrecord = re.compile(r'"#FFFF00">(\d+)[^"]+"#FFFF00">(\d+)[^"]+'\ - '"#FFFF00">(\d+)') + _gkrecord = re.compile(r'"#FFFF00">(\d+)[^"]+"#FFFF00">(\d+)[^"]+' + r'"#FFFF00">(\d+)') _gkteam = re.compile(r'Team:(<.*?>)+(?P.*?)') _gkseen = re.compile(r'(seen on GK:\s+([^[]+ago)|.*?is hiding.*?)') def __init__(self): @@ -158,8 +158,8 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): if ('User %s not found!' % name) in profile: raise callbacks.Error, 'No user %s exists.' % name else: - raise callbacks.Error,'The format of the page was odd. %s' %\ - conf.replyPossibleBug + raise callbacks.Error,'The format of the page was odd. %s' % \ + conf.replyPossibleBug except urllib2.URLError: raise callbacks.Error, 'Couldn\'t connect to gameknot.com' @@ -236,8 +236,8 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): (gameTitle, wName, wStats, bName, bStats, toMove) irc.reply(s, prefixName=False) except ValueError: - irc.error('That doesn\'t appear to be a proper Gameknot game.'\ - ' (%s)' % conf.replyPossibleBug) + s = 'That doesn\'t appear to be a proper Gameknot game.' + irc.errorPossibleBug(s) except Exception, e: irc.error(utils.exnToString(e)) gameknotSnarfer = privmsgs.urlSnarfer(gameknotSnarfer) diff --git a/plugins/Google.py b/plugins/Google.py index 2e388890f..80978d7b2 100644 --- a/plugins/Google.py +++ b/plugins/Google.py @@ -84,7 +84,7 @@ def configure(onStart, afterConnect, advanced): if yn('Do you want the Google Groups link snarfer enabled by ' 'default?') == 'y': onStart.append('Google config groups-snarfer on') - if yn('Do you want the Google search snarfer enabled by default?')\ + if yn('Do you want the Google search snarfer enabled by default?') \ == 'y': onStart.append('Google config search-snarfer on') if 'load Alias' not in onStart: @@ -92,7 +92,7 @@ def configure(onStart, afterConnect, advanced): if yn('Would you like to load the Alias module now?') == 'y': onStart.append('load Alias') else: - print 'You can still use the Google module, but you won\'t '\ + print 'You can still use the Google module, but you won\'t ' \ 'have these extra commands enabled.' return onStart.append('alias googlelinux "google --restrict=linux $1"') @@ -289,12 +289,11 @@ class Google(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): useful for making sure you don't go over your 1000 requests/day limit. """ recent = len(last24hours) - irc.reply('This google module has been called %s time%stotal; '\ - '%s time%sin the past 24 hours. ' \ - 'Google has spent %s seconds searching for me.' % \ - (totalSearches, totalSearches != 1 and 's ' or ' ', - recent, recent != 1 and 's ' or ' ', - totalTime)) + irc.reply('This google module has been called %s total; ' + '%s in the past 24 hours. ' + 'Google has spent %s seconds searching for me.' % + (utils.nItems('time', totalSearches), + utils.nItems('time', recent), totalTime)) def googleSnarfer(self, irc, msg, match): r"^google\s+(.*)$" @@ -320,7 +319,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): r"http://groups.google.com/[^\s]+" if not self.configurables.get('groups-snarfer', channel=msg.args[0]): return - request = urllib2.Request(match.group(0), headers=\ + request = urllib2.Request(match.group(0), headers= \ {'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'}) fd = urllib2.urlopen(request) text = fd.read() @@ -350,8 +349,8 @@ class Google(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): irc.reply('Google Groups: %s, %s' % (mGroup.group(1), mThread.group(1)), prefixName = False) else: - irc.error('That doesn\'t appear to be a proper '\ - 'Google Groups page. (%s)' % conf.replyPossibleBug) + irc.errorPossibleBug('That doesn\'t appear to be a proper ' + 'Google Groups page.') googleGroups = privmsgs.urlSnarfer(googleGroups) diff --git a/plugins/Http.py b/plugins/Http.py index d38bcb40b..9aafd48a9 100644 --- a/plugins/Http.py +++ b/plugins/Http.py @@ -172,7 +172,7 @@ class Http(callbacks.Privmsg): previous day of a given compny (represented by a stock symbol). """ symbol = privmsgs.getArgs(args) - url = 'http://finance.yahoo.com/d/quotes.csv?s=%s'\ + url = 'http://finance.yahoo.com/d/quotes.csv?s=%s' \ '&f=sl1d1t1c1ohgv&e=.csv' % symbol quote = webutils.getUrl(url) data = quote.split(',') @@ -226,7 +226,7 @@ class Http(callbacks.Privmsg): if s.startswith('[not an acronym]'): defs[i] = s.split('is ', 1)[1] if len(defs) == 0: - irc.reply('No definitions found. (%s)' % conf.replyPossibleBug) + irc.reply('No definitions found.') else: s = ', or '.join(defs) irc.reply('%s could be %s' % (acronym, s)) @@ -268,11 +268,11 @@ class Http(callbacks.Privmsg): beta = version.strip() finally: fd.close() - irc.reply('The latest stable kernel is %s; ' \ - 'the latest beta kernel is %s.' % (stable, beta)) + irc.reply('The latest stable kernel is %s; ' + 'the latest beta kernel is %s.' % (stable, beta)) - _pgpkeyre = re.compile(r'pub\s+\d{4}\w/([^<]+)[^>]+>([^<]+)') + _pgpkeyre = re.compile(r'pub\s+\d{4}\w/' + r'([^<]+)[^>]+>([^<]+)') def pgpkey(self, irc, msg, args): """ @@ -299,8 +299,8 @@ class Http(callbacks.Privmsg): fd.close() _filextre = re.compile( - r'Extension:.*?.*?\s+\s+(?:]+>([^<]+)\s+|([^<]+))\s+'\ + r'Extension:.*?.*?\s+\s+(?:]+>([^<]+)\s+|([^<]+))\s+' r'(?:]+>([^<]+)|] diff --git a/plugins/Quotes.py b/plugins/Quotes.py index 6b718dde2..0d7760561 100644 --- a/plugins/Quotes.py +++ b/plugins/Quotes.py @@ -94,7 +94,7 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg): WHERE added_by=%s AND added_at=%s AND quote=%s""" cursor.execute(sql, msg.nick, quotetime, quote) quoteid = cursor.fetchone()[0] - irc.reply('%s (Quote #%s added)' % (conf.replySuccess, quoteid)) + irc.replySuccess('(Quote #%s added)' % quoteid) def num(self, irc, msg, args): """[] @@ -222,17 +222,18 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg): (id, added_by, added_at, quote) = cursor.fetchone() timestamp = time.strftime(conf.humanTimestampFormat, time.localtime(int(added_at))) - irc.reply('Quote %r added by %s at %s.' % \ - (quote, added_by, timestamp)) + irc.reply('Quote %r added by %s at %s.' % + (quote, added_by, timestamp)) else: irc.error('There isn\'t a quote with that id.') - def remove(self, irc, msg, args, channel): + def remove(self, irc, msg, args): """[] Removes quote from the quotes database for . is only necessary if the message isn't sent in the channel itself. """ + channel = privmsgs.getChannel(msg, args) id = privmsgs.getArgs(args) db = self.getDb(channel) cursor = db.cursor() diff --git a/plugins/Relay.py b/plugins/Relay.py index 4f70a194d..5034c2a32 100644 --- a/plugins/Relay.py +++ b/plugins/Relay.py @@ -472,7 +472,7 @@ class Relay(callbacks.Privmsg, configurable.Mixin): identify = '' else: identify = '' - s = '%s (%s) has been%s on server %s since %s (idle for %s) and '\ + s = '%s (%s) has been%s on server %s since %s (idle for %s) and ' \ '%s.%s' % (user, hostmask, identify, server, signon, idle, channels, away) replyIrc.reply(replyMsg, s) diff --git a/plugins/Scheduler.py b/plugins/Scheduler.py index b1f3426a9..18efae96c 100644 --- a/plugins/Scheduler.py +++ b/plugins/Scheduler.py @@ -89,7 +89,7 @@ class Scheduler(callbacks.Privmsg): f = self._makeCommandFunction(irc, msg, command) id = schedule.addEvent(f, time.time() + seconds) self.events[str(id)] = command - irc.reply('%s Event #%s added.' % (conf.replySuccess, id)) + irc.replySuccess('Event #%s added.' % id) def remove(self, irc, msg, args): """ @@ -106,7 +106,7 @@ class Scheduler(callbacks.Privmsg): pass try: schedule.removeEvent(id) - irc.reply(conf.replySuccess) + irc.replySuccess() except KeyError: irc.error('Invalid event id.') else: diff --git a/plugins/Services.py b/plugins/Services.py index 842af56f5..3bb57a5ae 100644 --- a/plugins/Services.py +++ b/plugins/Services.py @@ -82,7 +82,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg): ChanServ, respectively, They default to NickServ and ChanServ. """ if ircutils.isChannel(msg.args[0]): - irc.error(conf.replyRequiresPrivacy) + irc.errorRequiresPrivacy() return (self.nick, self.password, nickserv, chanserv) = \ privmsgs.getArgs(args, required=2, optional=2) diff --git a/plugins/Sourceforge.py b/plugins/Sourceforge.py index ee0a6ebd2..17d838fae 100644 --- a/plugins/Sourceforge.py +++ b/plugins/Sourceforge.py @@ -104,10 +104,10 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): regexps = ['sfSnarfer'] _reopts = re.I - _infoRe = re.compile(r'(\d+)([^<]+)', _reopts) - _hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100'\ - '&_group=100&order=artifact_id&sort=DESC' + _infoRe = re.compile(r'(\d+)([^<]+)', re.I) + _hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100' \ + '&_group=100&order=artifact_id&sort=DESC' _resolution=re.compile(r'(Resolution): (.+?)',_reopts) _assigned=re.compile(r'(Assigned To): (.+?)', _reopts) _submitted = re.compile(r'(Submitted By):
([^<]+)', _reopts) @@ -167,8 +167,8 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): if len(resp) > 10: resp = imap(lambda s: utils.ellipsisify(s, 50), resp) return '%s' % utils.commaAndify(resp) - raise callbacks.Error, 'No Trackers were found. (%s)' %\ - conf.replyPossibleBug + raise callbacks.Error, 'No Trackers were found. (%s)' % \ + conf.replyPossibleBug except webutils.WebError, e: raise callbacks.Error, e.msg() @@ -180,8 +180,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): if resp: irc.reply(resp[0]) return - irc.error('No Trackers were found. (%s)' % - conf.replyPossibleBug) + irc.errorPossibleBug('No Trackers were found.') except webutils.WebError, e: irc.error(e.msg()) @@ -195,8 +194,9 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): project = privmsgs.getArgs(args, required=0, optional=1) try: int(project) - irc.error('Use the bug command to get information about a '\ - 'specific bug.') + # They want the bug command, they're giving us an id#. + s = 'Use the bug command to get information about a specific bug.' + irc.error(s) return except ValueError: pass @@ -246,8 +246,9 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): project = privmsgs.getArgs(args, required=0, optional=1) try: int(project) - irc.error('Use the rfe command to get information about a '\ - 'specific rfe.') + # They want a specific RFE, they gave us its id#. + s = 'Use the rfe command to get information about a specific rfe.' + irc.error(s) return except ValueError: pass @@ -309,9 +310,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin): head = '%s #%s:' % (ircutils.bold(linktype), num) resp.append(desc) else: - s = '%s does not appear to be a proper Sourceforge ' \ - 'Tracker page (%s)' % (url, conf.replyPossibleBug) - self.log.warning(s) + self.log.warning('Invalid Tracker page snarfed: %s', url) for r in self._res: m = r.search(s) if m: diff --git a/plugins/Todo.py b/plugins/Todo.py index 18afe83f7..7ebc7ef7d 100644 --- a/plugins/Todo.py +++ b/plugins/Todo.py @@ -208,7 +208,7 @@ class Todo(callbacks.Privmsg): cursor.execute("""SELECT id FROM todo WHERE added_at=%s AND userid=%s""", now, id) todoId = cursor.fetchone()[0] - irc.reply('%s (Todo #%s added)' % (conf.replySuccess, todoId)) + irc.replySuccess('(Todo #%s added)' % (todoId)) def remove(self, irc, msg, args): """ [ ...] @@ -235,9 +235,9 @@ class Todo(callbacks.Privmsg): invalid.append(taskid) #print 'Invalid tasks: %s' % repr(invalid) if invalid: - irc.error('No tasks were removed because the following '\ - 'tasks could not be removed: %s' % \ - utils.commaAndify(invalid)) + irc.error('No tasks were removed because the following ' + 'tasks could not be removed: %s' % + utils.commaAndify(invalid)) else: for taskid in tasks: cursor.execute("""UPDATE todo SET active = 0 WHERE id = %s""", diff --git a/plugins/URL.py b/plugins/URL.py index 5ef8dda97..1646e6268 100644 --- a/plugins/URL.py +++ b/plugins/URL.py @@ -304,9 +304,8 @@ class URL(callbacks.PrivmsgCommandAndRegexp, self._updateTinyDb(url, tinyurl, channel) irc.reply(tinyurl) else: - s = 'Could not parse the TinyURL.com results page. (%s)' % \ - conf.replyPossibleBug - irc.error(s) + s = 'Could not parse the TinyURL.com results page.' + irc.errorPossibleBug(s) tiny = privmsgs.thread(tiny) def num(self, irc, msg, args): @@ -320,7 +319,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp, cursor = db.cursor() cursor.execute("""SELECT COUNT(*) FROM urls""") (count,) = cursor.fetchone() - irc.reply('I have %s %s in my database.' % \ + irc.reply('I have %s %s in my database.' % (count, int(count) == 1 and 'URL' or 'URLs')) def last(self, irc, msg, args): diff --git a/plugins/Unix.py b/plugins/Unix.py index 2979b1f5f..59f34b6fa 100644 --- a/plugins/Unix.py +++ b/plugins/Unix.py @@ -91,9 +91,9 @@ def configure(onStart, afterConnect, advanced): def progstats(): pw = pwd.getpwuid(os.getuid()) - response = 'Process ID %i running as user "%s" and as group "%s" '\ - 'from directory "%s" with the command line "%s". '\ - 'Running on Python %s.' %\ + response = 'Process ID %i running as user "%s" and as group "%s" ' \ + 'from directory "%s" with the command line "%s". ' \ + 'Running on Python %s.' % \ (os.getpid(), pw[0], pw[3], os.getcwd(), " ".join(sys.argv), sys.version.translate(string.ascii, '\r\n')) diff --git a/plugins/Weather.py b/plugins/Weather.py index c94c8f7d3..7dd76bdf4 100644 --- a/plugins/Weather.py +++ b/plugins/Weather.py @@ -62,22 +62,22 @@ class Weather(callbacks.Privmsg): irc.error(str(e)) _cityregex = re.compile( - r''\ - r'(.*?), (.*?),(.*?)', re.IGNORECASE) + r'' + r'(.*?), (.*?),(.*?)', re.I) _interregex = re.compile( - r''\ - r'([^,]+), ([^<]+)', re.IGNORECASE) + r'' + r'([^,]+), ([^<]+)', re.I) _condregex = re.compile( - r''\ - r'([^<]+)', re.IGNORECASE) + r'' + r'([^<]+)', re.I) _tempregex = re.compile( - r''\ - r'([^<]+)', re.IGNORECASE) + r'' + r'([^<]+)', re.I) _chillregex = re.compile( - r'Wind Chill:\s+'\ + r'Wind Chill:\s+' r'([^<]+)', re.I | re.S) _heatregex = re.compile( - r'Heat Index:\s+'\ + r'Heat Index:\s+' r'([^<]+)', re.I | re.S) # States _realStates = sets.Set(['ak', 'al', 'ar', 'az', 'ca', 'co', 'ct', @@ -124,16 +124,14 @@ class Weather(callbacks.Privmsg): state = '' if country in self._countryMap.keys(): country = self._countryMap[country] - url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?'\ - 'pass=&dpp=&forecast=zandh&config=&'\ - 'place=%s&state=%s&country=%s' % \ - (city, state, country) + url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?' \ + 'pass=&dpp=&forecast=zandh&config=&' \ + 'place=%s&state=%s&country=%s' % (city, state, country) html = webutils.getUrl(url) if 'was not found' in html: - url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?'\ - 'pass=&dpp=&forecast=zandh&config=&'\ - 'place=%s&state=&country=%s' % \ - (city, state) + url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?' \ + 'pass=&dpp=&forecast=zandh&config=&' \ + 'place=%s&state=&country=%s' % (city, state) html = webutils.getUrl(url) if 'was not found' in html: irc.error('No such location could be found.') @@ -144,7 +142,7 @@ class Weather(callbacks.Privmsg): zip = privmsgs.getArgs(args) zip = zip.replace(',', '') zip = zip.lower().split() - url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?'\ + url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?' \ 'config=&forecast=zandh&pands=%s&Submit=GO' % args[0] html = webutils.getUrl(url) if 'was not found' in html: diff --git a/plugins/Words.py b/plugins/Words.py index 8621d4695..e2e63071b 100644 --- a/plugins/Words.py +++ b/plugins/Words.py @@ -184,7 +184,7 @@ class Words(callbacks.Privmsg, configurable.Mixin): return else: addWord(self.dbHandler.getDb(), word, commit=True) - irc.reply(msg, conf.replySuccess) + irc.replySuccess() def crossword(self, irc, msg, args): """ diff --git a/src/Admin.py b/src/Admin.py index 407598fe8..3e858f3c1 100755 --- a/src/Admin.py +++ b/src/Admin.py @@ -141,7 +141,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg): to protect the secrecy of secret channels. """ if ircutils.isChannel(msg.args[0]): - irc.error(conf.replyRequiresPrivacy) + irc.errorRequiresPrivacy() return L = irc.state.channels.keys() if L: diff --git a/src/Owner.py b/src/Owner.py index 5ec39a7df..e4bf62f56 100644 --- a/src/Owner.py +++ b/src/Owner.py @@ -147,7 +147,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): if len(ambiguousCommands) == 1: # Common case. (command, names) = ambiguousCommands.popitem() names.sort() - s = 'The command %r is available in the %s plugins. '\ + s = 'The command %r is available in the %s plugins. ' \ 'Please specify the plugin whose command you ' \ 'wish to call by using its name as a command ' \ 'before calling it.' % \ @@ -160,7 +160,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): 'plugins' % (command, utils.commaAndify(names))) s = '%s; please specify from which plugins to ' \ - 'call these commands.' % '; '.join(L) + 'call these commands.' % '; '.join(L) irc.queueMsg(callbacks.error(msg, s)) else: callbacks.IrcObjectProxy(irc, msg, tokens) diff --git a/src/User.py b/src/User.py index 2c6995365..30794012b 100755 --- a/src/User.py +++ b/src/User.py @@ -286,7 +286,7 @@ class User(callbacks.Privmsg): specified, returns the hostmasks of the user calling the command. """ if ircutils.isChannel(msg.args[0]): - irc.error(conf.replyRequiresPrivacy) + irc.errorRequiresPrivacy() return name = privmsgs.getArgs(args, required=0, optional=1) try: diff --git a/src/callbacks.py b/src/callbacks.py index 35024f4a2..40dd6a133 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -299,15 +299,17 @@ class RichReplyMethods(object): def replySuccess(self, s='', **kwargs): self.reply(self._makeReply(conf.replySuccess, s), **kwargs) - def replyPossibleBug(self, s='', **kwargs): - self.reply(self._makeReply(conf.replyPossibleBug, s), **kwargs) - def replyError(self, s='', **kwargs): self.reply(self._makeReply(conf.replyError, s), **kwargs) def errorNoCapability(self, capability, s='', **kwargs): self.error(self._makeReply(conf.replyNoCapability % s, s), **kwargs) + def errorPossibleBug(self, s='', **kwargs): + if s: + s += ' (%s)' % conf.replyPossibleBug + self.error(s, **kwargs) + def errorNotRegistered(self, s='', **kwargs): self.error(self._makeReply(conf.replyNotRegistered, s), **kwargs) diff --git a/src/ircdb.py b/src/ircdb.py index b574de2e1..cda5a701d 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -211,8 +211,8 @@ class IrcUser(object): self.hostmasks = hostmasks def __repr__(self): - return '%s(ignore=%s, password=%r, name=%r, hashed=%r, '\ - 'capabilities=%r, hostmasks=%r, secure=%r)\n' %\ + return '%s(ignore=%s, password=%r, name=%r, hashed=%r, ' \ + 'capabilities=%r, hostmasks=%r, secure=%r)\n' % \ (self.__class__.__name__, self.ignore, self.password, self.name, self.hashed, self.capabilities, self.hostmasks, self.secure) @@ -308,8 +308,8 @@ class IrcChannel(object): self.lobotomized = lobotomized def __repr__(self): - return '%s(bans=%r, ignores=%r, capabilities=%r, '\ - 'lobotomized=%r, defaultAllow=%s)\n' %\ + return '%s(bans=%r, ignores=%r, capabilities=%r, ' \ + 'lobotomized=%r, defaultAllow=%s)\n' % \ (self.__class__.__name__, self.bans, self.ignores, self.capabilities, self.lobotomized, self.defaultAllow)