Huge commit to finish refactoring of replies.

This commit is contained in:
Jeremy Fincher 2004-01-08 23:03:48 +00:00
parent 5700a69aed
commit 1c03464fd9
35 changed files with 149 additions and 156 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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:])))

View File

@ -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))

View File

@ -230,7 +230,7 @@ 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)' % \
irc.reply('No package found for %s (%s)' %
(urllib.unquote(package), branch))
else:
tableData = m.group(1)

View File

@ -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 = []

View File

@ -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'<title>eBay item (\d+) \([^)]+\) - ([^<]+)</title>',
_reopts)
_bid = re.compile(r'((?:Current|Starting) bid):.+?<b>([^<]+?)<font',
_reopts)
_bid = re.compile(r'((?:Current|Starting) bid):.+?<b>([^<]+?)<fo', _reopts)
_winningBid = re.compile(r'(Winning bid|Sold for):.+?<b>([^<]+?)<font',
_reopts)
_time = re.compile(r'(Time left):.+?<b>([^<]+?)</b>', _reopts)
_bidder = re.compile(r'(High bidder):.+?(?:">(User ID) (kept private)'\
'</font>|<a href[^>]+>([^<]+)</a>.+?<a href[^>]+>(\d+)</a>)', _reopts)
_winningBidder = re.compile(r'(Winning bidder|Buyer):.+?<a href[^>]+>'\
'([^<]+)</a>.+?<a href[^>]+>(\d+)</a>', _reopts)
_bidder = re.compile(r'(High bidder):.+?(?:">(User ID) (kept private)'
r'</font>|<a href[^>]+>([^<]+)</a>.+?'
r'<a href[^>]+>(\d+)</a>)', _reopts)
_winningBidder = re.compile(r'(Winning bidder|Buyer):.+?<a href[^>]+>'
r'([^<]+)</a>.+?<a href[^>]+>(\d+)</a>',_reopts)
_buyNow = re.compile(r'alt="(Buy It Now)">.*?<b>([^<]+)</b>', _reopts)
_seller = re.compile(r'(Seller information).+?<a href[^>]+>([^<]+)</a>'\
'.+ViewFeedback.+">(\d+)</a>', _reopts)
_searches = (_bid, _winningBid, _time, _bidder, _winningBidder, _buyNow,
_seller)
_seller = re.compile(r'(Seller information).+?<a href[^>]+>([^<]+)</a>'
r'.+ViewFeedback.+">(\d+)</a>', _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:

View File

@ -134,7 +134,7 @@ 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 % \
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:

View File

@ -268,9 +268,9 @@ 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.' % \
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):

View File

@ -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):
"""<text>

View File

@ -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)

View File

@ -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):
"""[<channel>] <lart|excuse|insult|praise> <id>
@ -500,7 +498,7 @@ Class = FunDB
if __name__ == '__main__':
import sys
if len(sys.argv) < 3 or len(sys.argv) > 4:
print 'Usage: %s <channel> <larts|excuses|insults|zipcodes> file'\
print 'Usage: %s <channel> <larts|excuses|insults|zipcodes> file' \
' [<console>]' % sys.argv[0]
sys.exit(-1)
if len(sys.argv) == 4:

View File

@ -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'<font color="#FFFF33">(\d+)</font>')
_gkgames = re.compile(r's:</td><td class=sml>(\d+)</td></tr>')
_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<name>.*?)</span>')
_gkseen = re.compile(r'(seen on GK:\s+([^[]+ago)|.*?is hiding.*?)')
def __init__(self):
@ -158,7 +158,7 @@ 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' %\
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)

View File

@ -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)

View File

@ -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; ' \
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/<a '\
'href="([^"]+)">([^<]+)</a>[^>]+>([^<]+)</a>')
_pgpkeyre = re.compile(r'pub\s+\d{4}\w/<a href="([^"]+)">'
r'([^<]+)</a>[^>]+>([^<]+)</a>')
def pgpkey(self, irc, msg, args):
"""<search words>
@ -299,8 +299,8 @@ class Http(callbacks.Privmsg):
fd.close()
_filextre = re.compile(
r'<strong>Extension:</strong>.*?<tr>.*?</tr>\s+<tr>\s+<td colspan='\
r'"2">(?:<a href[^>]+>([^<]+)</a>\s+|([^<]+))</td>\s+<td>'\
r'<strong>Extension:</strong>.*?<tr>.*?</tr>\s+<tr>\s+<td colspan='
r'"2">(?:<a href[^>]+>([^<]+)</a>\s+|([^<]+))</td>\s+<td>'
r'(?:<a href[^>]+>([^<]+)</a>|<img src="images/spacer.gif"(.))',
re.I|re.S)
def extension(self, irc, msg, args):

View File

@ -202,10 +202,6 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
orderby = 'subtracted'
elif kind == 'active':
orderby = 'added+subtracted'
else:
self.log.error('Impossible condition in most: kind=%s' % kind)
irc.error(conf.replyPossibleBug)
return
sql = "SELECT name, %s FROM karma ORDER BY %s DESC LIMIT %s" % \
(orderby, orderby,
self.configurables.get('karma-most-display', channel))

View File

@ -178,7 +178,7 @@ class Lookup(callbacks.Privmsg):
cursor.execute("CREATE INDEX %s_keys ON %s (key)" %(name,name))
db.commit()
self.addCommand(name)
irc.reply('%s (lookup %s added)' % (conf.replySuccess, name))
irc.replySuccess('(lookup %s added)' % name)
add = privmsgs.checkCapability(add, 'admin')
def addCommand(self, name):

View File

@ -121,7 +121,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
else:
options = cursor.fetchall()
optionstr = 'Options:'
optionstr += ''.join([' %s: %r' % (id, option) \
optionstr += ''.join([' %s: %r' % (id, option)
for id, option in options])
pollstr = 'Poll #%s: %r started by %s. %s. Poll is %s.' % \
(poll_id, question, starter, optionstr, statusstr)
@ -148,7 +148,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
db.commit()
cursor.execute("""SELECT id FROM polls WHERE question=%s""", question)
id = cursor.fetchone()[0]
irc.reply('%s (poll #%s)' % (conf.replySuccess, id))
irc.replySuccess('(poll #%s)' % id)
def close(self, irc, msg, args):
"""[<channel>] <id>

View File

@ -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):
"""[<channel>]
@ -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.' % \
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):
"""[<channel>] <id>
Removes quote <id> from the quotes database for <channel>. <channel>
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()

View File

@ -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)

View File

@ -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):
"""<id>
@ -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:

View File

@ -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)

View File

@ -104,9 +104,9 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
regexps = ['sfSnarfer']
_reopts = re.I
_infoRe = re.compile(r'<td nowrap>(\d+)</td><td><a href='\
'"([^"]+)">([^<]+)</a>', _reopts)
_hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100'\
_infoRe = re.compile(r'<td nowrap>(\d+)</td><td><a href='
r'"([^"]+)">([^<]+)</a>', re.I)
_hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100' \
'&_group=100&order=artifact_id&sort=DESC'
_resolution=re.compile(r'<b>(Resolution):</b> <a.+?<br>(.+?)</td>',_reopts)
_assigned=re.compile(r'<b>(Assigned To):</b> <a.+?<br>(.+?)</td>', _reopts)
@ -167,7 +167,7 @@ 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)' %\
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:

View File

@ -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):
"""<task id> [<task id> ...]
@ -235,8 +235,8 @@ 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' % \
irc.error('No tasks were removed because the following '
'tasks could not be removed: %s' %
utils.commaAndify(invalid))
else:
for taskid in tasks:

View File

@ -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):

View File

@ -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'))

View File

@ -62,22 +62,22 @@ class Weather(callbacks.Privmsg):
irc.error(str(e))
_cityregex = re.compile(
r'<td><font size="4" face="arial"><b>'\
r'(.*?), (.*?),(.*?)</b></font></td>', re.IGNORECASE)
r'<td><font size="4" face="arial"><b>'
r'(.*?), (.*?),(.*?)</b></font></td>', re.I)
_interregex = re.compile(
r'<td><font size="4" face="arial"><b>'\
r'([^,]+), ([^<]+)</b></font></td>', re.IGNORECASE)
r'<td><font size="4" face="arial"><b>'
r'([^,]+), ([^<]+)</b></font></td>', re.I)
_condregex = re.compile(
r'<td width="100%" colspan="2" align="center"><strong>'\
r'<font face="arial">([^<]+)</font></strong></td>', re.IGNORECASE)
r'<td width="100%" colspan="2" align="center"><strong>'
r'<font face="arial">([^<]+)</font></strong></td>', re.I)
_tempregex = re.compile(
r'<td valign="top" align="right"><strong><font face="arial">'\
r'([^<]+)</font></strong></td>', re.IGNORECASE)
r'<td valign="top" align="right"><strong><font face="arial">'
r'([^<]+)</font></strong></td>', re.I)
_chillregex = re.compile(
r'Wind Chill</font></strong>:</small></a></td>\s+<td align="right">'\
r'Wind Chill</font></strong>:</small></a></td>\s+<td align="right">'
r'<small><font face="arial">([^<]+)</font></small></td>', re.I | re.S)
_heatregex = re.compile(
r'Heat Index</font></strong>:</small></a></td>\s+<td align="right">'\
r'Heat Index</font></strong>:</small></a></td>\s+<td align="right">'
r'<small><font face="arial">([^<]+)</font></small></td>', 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:

View File

@ -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):
"""<word>

View File

@ -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:

View File

@ -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.' % \

View File

@ -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:

View File

@ -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)

View File

@ -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)