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', 'Authors' : 'author',
'URL' : 'url' 'URL' : 'url'
} }
s = '"%(title)s", written by %(author)s; published by '\ s = '"%(title)s", written by %(author)s; published by ' \
'%(publisher)s%(url)s' '%(publisher)s%(url)s'
try: try:
book = amazon.searchByKeyword(isbn) book = amazon.searchByKeyword(isbn)
@ -169,7 +169,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin):
'Authors' : 'author', 'Authors' : 'author',
'URL' : 'url' 'URL' : 'url'
} }
s = '"%(title)s", written by %(author)s; published by '\ s = '"%(title)s", written by %(author)s; published by ' \
'%(publisher)s%(url)s' '%(publisher)s%(url)s'
try: try:
books = amazon.searchByKeyword(keyword) books = amazon.searchByKeyword(keyword)
@ -208,7 +208,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin):
'ReleaseDate' : 'date', 'ReleaseDate' : 'date',
'URL' : 'url' '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' '%(date)s; published by %(publisher)s%(url)s'
try: try:
videos = amazon.searchByKeyword(keyword, product_line=product) videos = amazon.searchByKeyword(keyword, product_line=product)
@ -306,7 +306,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin):
'Authors' : 'author', 'Authors' : 'author',
'URL' : 'url' 'URL' : 'url'
} }
s = '"%(title)s", written by %(author)s; published by '\ s = '"%(title)s", written by %(author)s; published by ' \
'%(publisher)s%(url)s' '%(publisher)s%(url)s'
try: try:
books = amazon.searchByAuthor(author) books = amazon.searchByAuthor(author)
@ -404,7 +404,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin):
'Media' : 'media', 'Media' : 'media',
'URL' : 'url' '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' '%(publisher)s%(url)s'
try: try:
items = amazon.searchByArtist(artist, product_line=product) items = amazon.searchByArtist(artist, product_line=product)
@ -444,7 +444,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin):
'ReleaseDate' : 'date', 'ReleaseDate' : 'date',
'URL' : 'url' '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' '%(date)s; published by %(publisher)s%(url)s'
try: try:
items = amazon.searchByActor(actor, product_line=product) items = amazon.searchByActor(actor, product_line=product)
@ -484,7 +484,7 @@ class Amazon(callbacks.Privmsg,configurable.Mixin):
'ReleaseDate' : 'date', 'ReleaseDate' : 'date',
'URL' : 'url' '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' '%(date)s; published by %(publisher)s%(url)s'
try: try:
items = amazon.searchByDirector(director, product_line=product) items = amazon.searchByDirector(director, product_line=product)

View File

@ -79,13 +79,13 @@ class Babelfish(callbacks.Privmsg):
translation = babelfish.translate(text, fromLang, toLang) translation = babelfish.translate(text, fromLang, toLang)
irc.reply(translation) irc.reply(translation)
except (KeyError, babelfish.LanguageNotAvailableError), e: except (KeyError, babelfish.LanguageNotAvailableError), e:
irc.error('%s is not a valid language. Valid languages ' \ irc.error('%s is not a valid language. Valid languages '
'include %s' % \ 'include %s' %
(e, utils.commaAndify(babelfish.available_languages))) (e, utils.commaAndify(babelfish.available_languages)))
except babelfish.BabelizerIOError, e: except babelfish.BabelizerIOError, e:
irc.error(e) irc.error(e)
except babelfish.BabelfishChangedError, 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') 'webpage format')
def babelize(self, irc, msg, args): def babelize(self, irc, msg, args):
@ -105,13 +105,13 @@ class Babelfish(callbacks.Privmsg):
translations = babelfish.babelize(text, fromLang, toLang) translations = babelfish.babelize(text, fromLang, toLang)
irc.reply(translations[-1]) irc.reply(translations[-1])
except (KeyError, babelfish.LanguageNotAvailableError), e: except (KeyError, babelfish.LanguageNotAvailableError), e:
irc.reply('%s is not a valid language. Valid languages ' \ irc.reply('%s is not a valid language. Valid languages '
'include %s' % \ 'include %s' %
(e, utils.commaAndify(babelfish.available_languages))) (e, utils.commaAndify(babelfish.available_languages)))
except babelfish.BabelizerIOError, e: except babelfish.BabelizerIOError, e:
irc.reply(e) irc.reply(e)
except babelfish.BabelfishChangedError, 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') 'webpage format')
def randomlanguage(self, irc, msg, args): def randomlanguage(self, irc, msg, args):

View File

@ -198,8 +198,9 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
return return
queryurl = '%s/xml.cgi?id=%s' % (match.group(1), match.group(2)) queryurl = '%s/xml.cgi?id=%s' % (match.group(1), match.group(2))
try: try:
summary = self._get_short_bug_summary(queryurl, 'Snarfed '\ summary = self._get_short_bug_summary(queryurl,
'Bugzilla URL', match.group(2)) 'Snarfed Bugzilla URL',
match.group(2))
except BugzillaError, e: except BugzillaError, e:
irc.reply(str(e)) irc.reply(str(e))
return return

View File

@ -452,7 +452,7 @@ class ChannelDB(plugins.ChannelDBHandler,
values = cursor.fetchone() values = cursor.fetchone()
s = '%s has sent %s; a total of %s, %s, ' \ s = '%s has sent %s; a total of %s, %s, ' \
'%s, and %s; %s of those messages %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, ' \ 'been kicked %s, changed the topic %s, ' \
'and changed the mode %s.' % \ 'and changed the mode %s.' % \
(name, utils.nItems('message', values.msgs), (name, utils.nItems('message', values.msgs),
@ -589,7 +589,7 @@ class ChannelDB(plugins.ChannelDBHandler,
username = ircdb.users.getUser(id).name username = ircdb.users.getUser(id).name
irc.error('%r has no wordstats' % username) irc.error('%r has no wordstats' % username)
return return
L = [('%r: %s' % (word, count)) for \ L = [('%r: %s' % (word, count)) for
(word, count) in cursor.fetchall()] (word, count) in cursor.fetchall()]
irc.reply(utils.commaAndify(L)) irc.reply(utils.commaAndify(L))
return return
@ -619,7 +619,7 @@ class ChannelDB(plugins.ChannelDBHandler,
ers = '%rer' % word ers = '%rer' % word
ret = 'Top %s ' % utils.nItems(ers, numResultsShown) ret = 'Top %s ' % utils.nItems(ers, numResultsShown)
ret += '(out of a total of %s seen):' % \ ret += '(out of a total of %s seen):' % \
utils.nItems(repr(word), total) utils.nItems(repr(word), total)
L = [] L = []
for (count, id) in results[:numResultsShown]: for (count, id) in results[:numResultsShown]:
username = ircdb.users.getUser(id).name username = ircdb.users.getUser(id).name

View File

@ -126,7 +126,7 @@ class ChannelLogger(irclib.IrcCallback):
for channel in msg.args[0].split(','): for channel in msg.args[0].split(','):
log = self.getLog(channel) log = self.getLog(channel)
self.timestamp(log) self.timestamp(log)
log.write('*** %s has joined %s\n' %\ log.write('*** %s has joined %s\n' %
(msg.nick or msg.prefix, channel)) (msg.nick or msg.prefix, channel))
def doKick(self, irc, msg): def doKick(self, irc, msg):
@ -138,7 +138,7 @@ class ChannelLogger(irclib.IrcCallback):
log = self.getLog(channel) log = self.getLog(channel)
self.timestamp(log) self.timestamp(log)
if kickmsg: if kickmsg:
log.write('*** %s was kicked by %s (%s)\n' % \ log.write('*** %s was kicked by %s (%s)\n' %
(target, msg.nick, kickmsg)) (target, msg.nick, kickmsg))
else: else:
log.write('*** %s was kicked by %s\n' % (target, msg.nick)) log.write('*** %s was kicked by %s\n' % (target, msg.nick))
@ -154,7 +154,7 @@ class ChannelLogger(irclib.IrcCallback):
if ircutils.isChannel(channel): if ircutils.isChannel(channel):
log = self.getLog(channel) log = self.getLog(channel)
self.timestamp(log) 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], (msg.nick or msg.prefix, msg.args[1],
' '.join(msg.args[2:]))) ' '.join(msg.args[2:])))

View File

@ -80,7 +80,7 @@ class DCC(callbacks.Privmsg):
s = 'Error trying to determine the external IP ' \ s = 'Error trying to determine the external IP ' \
'address of this machine via the host %s: %s' 'address of this machine via the host %s: %s'
self.log.warning(s, host, e) self.log.warning(s, host, e)
irc.reply(conf.replyError) irc.replyError()
return return
i = ircutils.dccIP(ip) i = ircutils.dccIP(ip)
sock.bind((host, 0)) sock.bind((host, 0))

View File

@ -230,8 +230,8 @@ class Debian(callbacks.Privmsg,
numberOfPackages = m.group(1) numberOfPackages = m.group(1)
m = self._debtablere.search(html) m = self._debtablere.search(html)
if m is None: if m is None:
irc.reply('No package found for %s (%s)' % \ irc.reply('No package found for %s (%s)' %
(urllib.unquote(package), branch)) (urllib.unquote(package), branch))
else: else:
tableData = m.group(1) tableData = m.group(1)
rows = tableData.split('</TR>') rows = tableData.split('</TR>')
@ -242,7 +242,7 @@ class Debian(callbacks.Privmsg,
s = '%s (%s)' % (pkgMatch.group(1), brMatch.group(1)) s = '%s (%s)' % (pkgMatch.group(1), brMatch.group(1))
responses.append(s) responses.append(s)
resp = 'Total matches: %s, shown: %s. %s' % \ resp = 'Total matches: %s, shown: %s. %s' % \
(numberOfPackages, len(responses), ', '.join(responses)) (numberOfPackages, len(responses), ', '.join(responses))
irc.reply(resp) irc.reply(resp)
_incomingRe = re.compile(r'<a href="(.*?\.deb)">', re.I) _incomingRe = re.compile(r'<a href="(.*?\.deb)">', re.I)

View File

@ -129,7 +129,7 @@ class Dict(callbacks.Privmsg, configurable.Mixin):
if dictionary == '*': if dictionary == '*':
irc.reply('No definition for %r could be found.' % word) irc.reply('No definition for %r could be found.' % word)
else: 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))) (word, ircutils.bold(dictionary)))
return return
L = [] L = []

View File

@ -89,25 +89,25 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
callbacks.PrivmsgCommandAndRegexp.die(self) callbacks.PrivmsgCommandAndRegexp.die(self)
_reopts = re.I | re.S _reopts = re.I | re.S
_invalid = re.compile(r'(is invalid, still pending, or no longer in our '\ _invalid = re.compile(r'(is invalid, still pending, or no longer in our '
'database)', _reopts) r'database)', _reopts)
_info = re.compile(r'<title>eBay item (\d+) \([^)]+\) - ([^<]+)</title>', _info = re.compile(r'<title>eBay item (\d+) \([^)]+\) - ([^<]+)</title>',
_reopts) _reopts)
_bid = re.compile(r'((?:Current|Starting) bid):.+?<b>([^<]+?)<font', _bid = re.compile(r'((?:Current|Starting) bid):.+?<b>([^<]+?)<fo', _reopts)
_reopts)
_winningBid = re.compile(r'(Winning bid|Sold for):.+?<b>([^<]+?)<font', _winningBid = re.compile(r'(Winning bid|Sold for):.+?<b>([^<]+?)<font',
_reopts) _reopts)
_time = re.compile(r'(Time left):.+?<b>([^<]+?)</b>', _reopts) _time = re.compile(r'(Time left):.+?<b>([^<]+?)</b>', _reopts)
_bidder = re.compile(r'(High bidder):.+?(?:">(User ID) (kept private)'\ _bidder = re.compile(r'(High bidder):.+?(?:">(User ID) (kept private)'
'</font>|<a href[^>]+>([^<]+)</a>.+?<a href[^>]+>(\d+)</a>)', _reopts) r'</font>|<a href[^>]+>([^<]+)</a>.+?'
_winningBidder = re.compile(r'(Winning bidder|Buyer):.+?<a href[^>]+>'\ r'<a href[^>]+>(\d+)</a>)', _reopts)
'([^<]+)</a>.+?<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) _buyNow = re.compile(r'alt="(Buy It Now)">.*?<b>([^<]+)</b>', _reopts)
_seller = re.compile(r'(Seller information).+?<a href[^>]+>([^<]+)</a>'\ _seller = re.compile(r'(Seller information).+?<a href[^>]+>([^<]+)</a>'
'.+ViewFeedback.+">(\d+)</a>', _reopts) r'.+ViewFeedback.+">(\d+)</a>', _reopts)
_searches = (_bid, _winningBid, _time, _bidder, _winningBidder, _buyNow, _searches = (_bid, _winningBid, _time, _bidder,
_seller) _winningBidder, _buyNow, _seller)
_multiField = (_bidder, _winningBidder, _seller) _multiField = (_bidder, _winningBidder, _seller)
def auction(self, irc, msg, args): def auction(self, irc, msg, args):
@ -139,8 +139,6 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
ebaySnarfer = privmsgs.urlSnarfer(ebaySnarfer) ebaySnarfer = privmsgs.urlSnarfer(ebaySnarfer)
def _getResponse(self, url): def _getResponse(self, url):
def bold(m):
return (ircutils.bold(m[0]),) + m[1:]
try: try:
fd = urllib2.urlopen(url) fd = urllib2.urlopen(url)
s = fd.read() s = fd.read()
@ -157,6 +155,8 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
resp.append('%s%s: %s' % (ircutils.bold('Item #'), resp.append('%s%s: %s' % (ircutils.bold('Item #'),
ircutils.bold(num), ircutils.bold(num),
utils.htmlToText(desc))) utils.htmlToText(desc)))
def bold(L):
return (ircutils.bold(L[0]),) + L[1:]
for r in self._searches: for r in self._searches:
m = r.search(s) m = r.search(s)
if m: if m:

View File

@ -134,8 +134,8 @@ class Enforcer(callbacks.Privmsg, configurable.Mixin):
irc.queueMsg(ircmsgs.topic(channel, self.topics[channel])) irc.queueMsg(ircmsgs.topic(channel, self.topics[channel]))
if self.configurables.get('revenge', channel): if self.configurables.get('revenge', channel):
irc.queueMsg(ircmsgs.kick(channel, msg.nick, irc.queueMsg(ircmsgs.kick(channel, msg.nick,
conf.replyNoCapability % \ conf.replyNoCapability %
_chanCap(channel, 'topic'))) _chanCap(channel, 'topic')))
else: else:
self.topics[channel] = msg.args[1] self.topics[channel] = msg.args[1]
@ -162,7 +162,7 @@ class Enforcer(callbacks.Privmsg, configurable.Mixin):
channel = msg.args[0] channel = msg.args[0]
kicked = msg.args[1].split(',') kicked = msg.args[1].split(',')
deop = False deop = False
if msg.nick != irc.nick and\ if msg.nick != irc.nick and \
not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')): not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')):
for nick in kicked: for nick in kicked:
hostmask = irc.state.nickToHostmask(nick) hostmask = irc.state.nickToHostmask(nick)
@ -187,7 +187,7 @@ class Enforcer(callbacks.Privmsg, configurable.Mixin):
channel = msg.args[0] channel = msg.args[0]
if not ircutils.isChannel(channel) or msg.nick == self.chanserv: if not ircutils.isChannel(channel) or msg.nick == self.chanserv:
return return
if msg.nick != irc.nick and\ if msg.nick != irc.nick and \
not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')): not ircdb.checkCapability(msg.prefix, _chanCap(channel, 'op')):
for (mode, value) in ircutils.separateModes(msg.args[1:]): for (mode, value) in ircutils.separateModes(msg.args[1:]):
if value == msg.nick: if value == msg.nick:

View File

@ -268,10 +268,10 @@ class Factoids(plugins.ChannelDBHandler,
db.commit() db.commit()
irc.replySuccess() irc.replySuccess()
else: else:
irc.error('%s factoids have that key. ' \ irc.error('%s factoids have that key. '
'Please specify which one to remove, ' \ 'Please specify which one to remove, '
'or use * to designate all of them.' % \ 'or use * to designate all of them.' %
cursor.rowcount) cursor.rowcount)
def random(self, irc, msg, args): def random(self, irc, msg, args):
"""[<channel>] """[<channel>]

View File

@ -203,7 +203,7 @@ class Filter(callbacks.Privmsg):
s = s.translate(self._leettrans) s = s.translate(self._leettrans)
irc.reply(s) 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]))') r'([a-zA-Z])(?:\b|(?![a-zA-Z]))')
def scramble(self, irc, msg, args): def scramble(self, irc, msg, args):
"""<text> """<text>

View File

@ -286,7 +286,7 @@ class Fun(callbacks.Privmsg):
response = 'I have %s objects: %s modules, %s classes, %s functions, '\ response = 'I have %s objects: %s modules, %s classes, %s functions, '\
'%s dictionaries, %s lists, %s tuples, %s strings, and a ' \ '%s dictionaries, %s lists, %s tuples, %s strings, and a ' \
'few other odds and ends. ' \ 'few other odds and ends. ' \
'I have a total of %s references.' %\ 'I have a total of %s references.' % \
(len(objs), modules, classes, functions, (len(objs), modules, classes, functions,
dicts, lists, tuples, strings, refcounts) dicts, lists, tuples, strings, refcounts)
irc.reply(response) irc.reply(response)

View File

@ -142,8 +142,7 @@ class FunDB(callbacks.Privmsg, configurable.Mixin, plugins.ChannelDBHandler):
return return
if table == "lart" or table == "praise": if table == "lart" or table == "praise":
if '$who' not in s: if '$who' not in s:
irc.error('There must be a $who in the lart/praise '\ irc.error('There must be a $who in the lart/praise somewhere')
'somewhere.')
return return
elif table not in self._tables: elif table not in self._tables:
irc.error('"%s" is not valid. Valid values include %s.' % 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) sql = """SELECT id FROM %ss WHERE %s=%%s""" % (table, table)
cursor.execute(sql, s) cursor.execute(sql, s)
id = cursor.fetchone()[0] id = cursor.fetchone()[0]
response = '%s (%s #%s)' % (conf.replySuccess, table, id) irc.replySuccess('(%s #%s)' % (table, id))
irc.reply(response)
def remove(self, irc, msg, args): def remove(self, irc, msg, args):
"""[<channel>] <lart|excuse|insult|praise> <id> """[<channel>] <lart|excuse|insult|praise> <id>
@ -500,7 +498,7 @@ Class = FunDB
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
if len(sys.argv) < 3 or len(sys.argv) > 4: 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] ' [<console>]' % sys.argv[0]
sys.exit(-1) sys.exit(-1)
if len(sys.argv) == 4: 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 '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 'supybot sees such a URL, he will parse the web page for'
print 'information and reply with the results.\n' 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': 'n':
onStart.append('Gameknot toggle stat off') 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': 'default?') == 'n':
onStart.append('Gameknot toggle stat off') 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>') _gkrating = re.compile(r'<font color="#FFFF33">(\d+)</font>')
_gkgames = re.compile(r's:</td><td class=sml>(\d+)</td></tr>') _gkgames = re.compile(r's:</td><td class=sml>(\d+)</td></tr>')
_gkrecord = re.compile(r'"#FFFF00">(\d+)[^"]+"#FFFF00">(\d+)[^"]+'\ _gkrecord = re.compile(r'"#FFFF00">(\d+)[^"]+"#FFFF00">(\d+)[^"]+'
'"#FFFF00">(\d+)') r'"#FFFF00">(\d+)')
_gkteam = re.compile(r'Team:(<.*?>)+(?P<name>.*?)</span>') _gkteam = re.compile(r'Team:(<.*?>)+(?P<name>.*?)</span>')
_gkseen = re.compile(r'(seen on GK:\s+([^[]+ago)|.*?is hiding.*?)') _gkseen = re.compile(r'(seen on GK:\s+([^[]+ago)|.*?is hiding.*?)')
def __init__(self): def __init__(self):
@ -158,8 +158,8 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
if ('User %s not found!' % name) in profile: if ('User %s not found!' % name) in profile:
raise callbacks.Error, 'No user %s exists.' % name raise callbacks.Error, 'No user %s exists.' % name
else: 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 conf.replyPossibleBug
except urllib2.URLError: except urllib2.URLError:
raise callbacks.Error, 'Couldn\'t connect to gameknot.com' 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) (gameTitle, wName, wStats, bName, bStats, toMove)
irc.reply(s, prefixName=False) irc.reply(s, prefixName=False)
except ValueError: except ValueError:
irc.error('That doesn\'t appear to be a proper Gameknot game.'\ s = 'That doesn\'t appear to be a proper Gameknot game.'
' (%s)' % conf.replyPossibleBug) irc.errorPossibleBug(s)
except Exception, e: except Exception, e:
irc.error(utils.exnToString(e)) irc.error(utils.exnToString(e))
gameknotSnarfer = privmsgs.urlSnarfer(gameknotSnarfer) 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 ' if yn('Do you want the Google Groups link snarfer enabled by '
'default?') == 'y': 'default?') == 'y':
onStart.append('Google config groups-snarfer on') 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': == 'y':
onStart.append('Google config search-snarfer on') onStart.append('Google config search-snarfer on')
if 'load Alias' not in onStart: 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': if yn('Would you like to load the Alias module now?') == 'y':
onStart.append('load Alias') onStart.append('load Alias')
else: 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.' 'have these extra commands enabled.'
return return
onStart.append('alias googlelinux "google --restrict=linux $1"') 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. useful for making sure you don't go over your 1000 requests/day limit.
""" """
recent = len(last24hours) recent = len(last24hours)
irc.reply('This google module has been called %s time%stotal; '\ irc.reply('This google module has been called %s total; '
'%s time%sin the past 24 hours. ' \ '%s in the past 24 hours. '
'Google has spent %s seconds searching for me.' % \ 'Google has spent %s seconds searching for me.' %
(totalSearches, totalSearches != 1 and 's ' or ' ', (utils.nItems('time', totalSearches),
recent, recent != 1 and 's ' or ' ', utils.nItems('time', recent), totalTime))
totalTime))
def googleSnarfer(self, irc, msg, match): def googleSnarfer(self, irc, msg, match):
r"^google\s+(.*)$" r"^google\s+(.*)$"
@ -320,7 +319,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
r"http://groups.google.com/[^\s]+" r"http://groups.google.com/[^\s]+"
if not self.configurables.get('groups-snarfer', channel=msg.args[0]): if not self.configurables.get('groups-snarfer', channel=msg.args[0]):
return 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)'}) {'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'})
fd = urllib2.urlopen(request) fd = urllib2.urlopen(request)
text = fd.read() text = fd.read()
@ -350,8 +349,8 @@ class Google(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
irc.reply('Google Groups: %s, %s' % (mGroup.group(1), irc.reply('Google Groups: %s, %s' % (mGroup.group(1),
mThread.group(1)), prefixName = False) mThread.group(1)), prefixName = False)
else: else:
irc.error('That doesn\'t appear to be a proper '\ irc.errorPossibleBug('That doesn\'t appear to be a proper '
'Google Groups page. (%s)' % conf.replyPossibleBug) 'Google Groups page.')
googleGroups = privmsgs.urlSnarfer(googleGroups) 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). previous day of a given compny (represented by a stock symbol).
""" """
symbol = privmsgs.getArgs(args) 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 '&f=sl1d1t1c1ohgv&e=.csv' % symbol
quote = webutils.getUrl(url) quote = webutils.getUrl(url)
data = quote.split(',') data = quote.split(',')
@ -226,7 +226,7 @@ class Http(callbacks.Privmsg):
if s.startswith('[not an acronym]'): if s.startswith('[not an acronym]'):
defs[i] = s.split('is ', 1)[1] defs[i] = s.split('is ', 1)[1]
if len(defs) == 0: if len(defs) == 0:
irc.reply('No definitions found. (%s)' % conf.replyPossibleBug) irc.reply('No definitions found.')
else: else:
s = ', or '.join(defs) s = ', or '.join(defs)
irc.reply('%s could be %s' % (acronym, s)) irc.reply('%s could be %s' % (acronym, s))
@ -268,11 +268,11 @@ class Http(callbacks.Privmsg):
beta = version.strip() beta = version.strip()
finally: finally:
fd.close() 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)) 'the latest beta kernel is %s.' % (stable, beta))
_pgpkeyre = re.compile(r'pub\s+\d{4}\w/<a '\ _pgpkeyre = re.compile(r'pub\s+\d{4}\w/<a href="([^"]+)">'
'href="([^"]+)">([^<]+)</a>[^>]+>([^<]+)</a>') r'([^<]+)</a>[^>]+>([^<]+)</a>')
def pgpkey(self, irc, msg, args): def pgpkey(self, irc, msg, args):
"""<search words> """<search words>
@ -299,8 +299,8 @@ class Http(callbacks.Privmsg):
fd.close() fd.close()
_filextre = re.compile( _filextre = re.compile(
r'<strong>Extension:</strong>.*?<tr>.*?</tr>\s+<tr>\s+<td colspan='\ r'<strong>Extension:</strong>.*?<tr>.*?</tr>\s+<tr>\s+<td colspan='
r'"2">(?:<a href[^>]+>([^<]+)</a>\s+|([^<]+))</td>\s+<td>'\ r'"2">(?:<a href[^>]+>([^<]+)</a>\s+|([^<]+))</td>\s+<td>'
r'(?:<a href[^>]+>([^<]+)</a>|<img src="images/spacer.gif"(.))', r'(?:<a href[^>]+>([^<]+)</a>|<img src="images/spacer.gif"(.))',
re.I|re.S) re.I|re.S)
def extension(self, irc, msg, args): def extension(self, irc, msg, args):

View File

@ -202,10 +202,6 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
orderby = 'subtracted' orderby = 'subtracted'
elif kind == 'active': elif kind == 'active':
orderby = 'added+subtracted' 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" % \ sql = "SELECT name, %s FROM karma ORDER BY %s DESC LIMIT %s" % \
(orderby, orderby, (orderby, orderby,
self.configurables.get('karma-most-display', channel)) 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)) cursor.execute("CREATE INDEX %s_keys ON %s (key)" %(name,name))
db.commit() db.commit()
self.addCommand(name) self.addCommand(name)
irc.reply('%s (lookup %s added)' % (conf.replySuccess, name)) irc.replySuccess('(lookup %s added)' % name)
add = privmsgs.checkCapability(add, 'admin') add = privmsgs.checkCapability(add, 'admin')
def addCommand(self, name): def addCommand(self, name):

View File

@ -121,7 +121,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
else: else:
options = cursor.fetchall() options = cursor.fetchall()
optionstr = 'Options:' optionstr = 'Options:'
optionstr += ''.join([' %s: %r' % (id, option) \ optionstr += ''.join([' %s: %r' % (id, option)
for id, option in options]) for id, option in options])
pollstr = 'Poll #%s: %r started by %s. %s. Poll is %s.' % \ pollstr = 'Poll #%s: %r started by %s. %s. Poll is %s.' % \
(poll_id, question, starter, optionstr, statusstr) (poll_id, question, starter, optionstr, statusstr)
@ -148,7 +148,7 @@ class Poll(callbacks.Privmsg, plugins.ChannelDBHandler):
db.commit() db.commit()
cursor.execute("""SELECT id FROM polls WHERE question=%s""", question) cursor.execute("""SELECT id FROM polls WHERE question=%s""", question)
id = cursor.fetchone()[0] id = cursor.fetchone()[0]
irc.reply('%s (poll #%s)' % (conf.replySuccess, id)) irc.replySuccess('(poll #%s)' % id)
def close(self, irc, msg, args): def close(self, irc, msg, args):
"""[<channel>] <id> """[<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""" WHERE added_by=%s AND added_at=%s AND quote=%s"""
cursor.execute(sql, msg.nick, quotetime, quote) cursor.execute(sql, msg.nick, quotetime, quote)
quoteid = cursor.fetchone()[0] 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): def num(self, irc, msg, args):
"""[<channel>] """[<channel>]
@ -222,17 +222,18 @@ class Quotes(plugins.ChannelDBHandler, callbacks.Privmsg):
(id, added_by, added_at, quote) = cursor.fetchone() (id, added_by, added_at, quote) = cursor.fetchone()
timestamp = time.strftime(conf.humanTimestampFormat, timestamp = time.strftime(conf.humanTimestampFormat,
time.localtime(int(added_at))) 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)) (quote, added_by, timestamp))
else: else:
irc.error('There isn\'t a quote with that id.') 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> """[<channel>] <id>
Removes quote <id> from the quotes database for <channel>. <channel> Removes quote <id> from the quotes database for <channel>. <channel>
is only necessary if the message isn't sent in the channel itself. is only necessary if the message isn't sent in the channel itself.
""" """
channel = privmsgs.getChannel(msg, args)
id = privmsgs.getArgs(args) id = privmsgs.getArgs(args)
db = self.getDb(channel) db = self.getDb(channel)
cursor = db.cursor() cursor = db.cursor()

View File

@ -472,7 +472,7 @@ class Relay(callbacks.Privmsg, configurable.Mixin):
identify = '' identify = ''
else: else:
identify = '' 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, '%s.%s' % (user, hostmask, identify, server, signon, idle,
channels, away) channels, away)
replyIrc.reply(replyMsg, s) replyIrc.reply(replyMsg, s)

View File

@ -89,7 +89,7 @@ class Scheduler(callbacks.Privmsg):
f = self._makeCommandFunction(irc, msg, command) f = self._makeCommandFunction(irc, msg, command)
id = schedule.addEvent(f, time.time() + seconds) id = schedule.addEvent(f, time.time() + seconds)
self.events[str(id)] = command 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): def remove(self, irc, msg, args):
"""<id> """<id>
@ -106,7 +106,7 @@ class Scheduler(callbacks.Privmsg):
pass pass
try: try:
schedule.removeEvent(id) schedule.removeEvent(id)
irc.reply(conf.replySuccess) irc.replySuccess()
except KeyError: except KeyError:
irc.error('Invalid event id.') irc.error('Invalid event id.')
else: else:

View File

@ -82,7 +82,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
ChanServ, respectively, They default to NickServ and ChanServ. ChanServ, respectively, They default to NickServ and ChanServ.
""" """
if ircutils.isChannel(msg.args[0]): if ircutils.isChannel(msg.args[0]):
irc.error(conf.replyRequiresPrivacy) irc.errorRequiresPrivacy()
return return
(self.nick, self.password, nickserv, chanserv) = \ (self.nick, self.password, nickserv, chanserv) = \
privmsgs.getArgs(args, required=2, optional=2) privmsgs.getArgs(args, required=2, optional=2)

View File

@ -104,10 +104,10 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
regexps = ['sfSnarfer'] regexps = ['sfSnarfer']
_reopts = re.I _reopts = re.I
_infoRe = re.compile(r'<td nowrap>(\d+)</td><td><a href='\ _infoRe = re.compile(r'<td nowrap>(\d+)</td><td><a href='
'"([^"]+)">([^<]+)</a>', _reopts) r'"([^"]+)">([^<]+)</a>', re.I)
_hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100'\ _hrefOpts = '&set=custom&_assigned_to=0&_status=1&_category=100' \
'&_group=100&order=artifact_id&sort=DESC' '&_group=100&order=artifact_id&sort=DESC'
_resolution=re.compile(r'<b>(Resolution):</b> <a.+?<br>(.+?)</td>',_reopts) _resolution=re.compile(r'<b>(Resolution):</b> <a.+?<br>(.+?)</td>',_reopts)
_assigned=re.compile(r'<b>(Assigned To):</b> <a.+?<br>(.+?)</td>', _reopts) _assigned=re.compile(r'<b>(Assigned To):</b> <a.+?<br>(.+?)</td>', _reopts)
_submitted = re.compile(r'<b>(Submitted By):</b><br>([^<]+)</td>', _reopts) _submitted = re.compile(r'<b>(Submitted By):</b><br>([^<]+)</td>', _reopts)
@ -167,8 +167,8 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
if len(resp) > 10: if len(resp) > 10:
resp = imap(lambda s: utils.ellipsisify(s, 50), resp) resp = imap(lambda s: utils.ellipsisify(s, 50), resp)
return '%s' % utils.commaAndify(resp) return '%s' % utils.commaAndify(resp)
raise callbacks.Error, 'No Trackers were found. (%s)' %\ raise callbacks.Error, 'No Trackers were found. (%s)' % \
conf.replyPossibleBug conf.replyPossibleBug
except webutils.WebError, e: except webutils.WebError, e:
raise callbacks.Error, e.msg() raise callbacks.Error, e.msg()
@ -180,8 +180,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
if resp: if resp:
irc.reply(resp[0]) irc.reply(resp[0])
return return
irc.error('No Trackers were found. (%s)' % irc.errorPossibleBug('No Trackers were found.')
conf.replyPossibleBug)
except webutils.WebError, e: except webutils.WebError, e:
irc.error(e.msg()) irc.error(e.msg())
@ -195,8 +194,9 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
project = privmsgs.getArgs(args, required=0, optional=1) project = privmsgs.getArgs(args, required=0, optional=1)
try: try:
int(project) int(project)
irc.error('Use the bug command to get information about a '\ # They want the bug command, they're giving us an id#.
'specific bug.') s = 'Use the bug command to get information about a specific bug.'
irc.error(s)
return return
except ValueError: except ValueError:
pass pass
@ -246,8 +246,9 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
project = privmsgs.getArgs(args, required=0, optional=1) project = privmsgs.getArgs(args, required=0, optional=1)
try: try:
int(project) int(project)
irc.error('Use the rfe command to get information about a '\ # They want a specific RFE, they gave us its id#.
'specific rfe.') s = 'Use the rfe command to get information about a specific rfe.'
irc.error(s)
return return
except ValueError: except ValueError:
pass pass
@ -309,9 +310,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, configurable.Mixin):
head = '%s #%s:' % (ircutils.bold(linktype), num) head = '%s #%s:' % (ircutils.bold(linktype), num)
resp.append(desc) resp.append(desc)
else: else:
s = '%s does not appear to be a proper Sourceforge ' \ self.log.warning('Invalid Tracker page snarfed: %s', url)
'Tracker page (%s)' % (url, conf.replyPossibleBug)
self.log.warning(s)
for r in self._res: for r in self._res:
m = r.search(s) m = r.search(s)
if m: if m:

View File

@ -208,7 +208,7 @@ class Todo(callbacks.Privmsg):
cursor.execute("""SELECT id FROM todo cursor.execute("""SELECT id FROM todo
WHERE added_at=%s AND userid=%s""", now, id) WHERE added_at=%s AND userid=%s""", now, id)
todoId = cursor.fetchone()[0] 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): def remove(self, irc, msg, args):
"""<task id> [<task id> ...] """<task id> [<task id> ...]
@ -235,9 +235,9 @@ class Todo(callbacks.Privmsg):
invalid.append(taskid) invalid.append(taskid)
#print 'Invalid tasks: %s' % repr(invalid) #print 'Invalid tasks: %s' % repr(invalid)
if invalid: if invalid:
irc.error('No tasks were removed because the following '\ irc.error('No tasks were removed because the following '
'tasks could not be removed: %s' % \ 'tasks could not be removed: %s' %
utils.commaAndify(invalid)) utils.commaAndify(invalid))
else: else:
for taskid in tasks: for taskid in tasks:
cursor.execute("""UPDATE todo SET active = 0 WHERE id = %s""", cursor.execute("""UPDATE todo SET active = 0 WHERE id = %s""",

View File

@ -304,9 +304,8 @@ class URL(callbacks.PrivmsgCommandAndRegexp,
self._updateTinyDb(url, tinyurl, channel) self._updateTinyDb(url, tinyurl, channel)
irc.reply(tinyurl) irc.reply(tinyurl)
else: else:
s = 'Could not parse the TinyURL.com results page. (%s)' % \ s = 'Could not parse the TinyURL.com results page.'
conf.replyPossibleBug irc.errorPossibleBug(s)
irc.error(s)
tiny = privmsgs.thread(tiny) tiny = privmsgs.thread(tiny)
def num(self, irc, msg, args): def num(self, irc, msg, args):
@ -320,7 +319,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp,
cursor = db.cursor() cursor = db.cursor()
cursor.execute("""SELECT COUNT(*) FROM urls""") cursor.execute("""SELECT COUNT(*) FROM urls""")
(count,) = cursor.fetchone() (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')) (count, int(count) == 1 and 'URL' or 'URLs'))
def last(self, irc, msg, args): def last(self, irc, msg, args):

View File

@ -91,9 +91,9 @@ def configure(onStart, afterConnect, advanced):
def progstats(): def progstats():
pw = pwd.getpwuid(os.getuid()) pw = pwd.getpwuid(os.getuid())
response = 'Process ID %i running as user "%s" and as group "%s" '\ response = 'Process ID %i running as user "%s" and as group "%s" ' \
'from directory "%s" with the command line "%s". '\ 'from directory "%s" with the command line "%s". ' \
'Running on Python %s.' %\ 'Running on Python %s.' % \
(os.getpid(), pw[0], pw[3], (os.getpid(), pw[0], pw[3],
os.getcwd(), " ".join(sys.argv), os.getcwd(), " ".join(sys.argv),
sys.version.translate(string.ascii, '\r\n')) sys.version.translate(string.ascii, '\r\n'))

View File

@ -62,22 +62,22 @@ class Weather(callbacks.Privmsg):
irc.error(str(e)) irc.error(str(e))
_cityregex = re.compile( _cityregex = re.compile(
r'<td><font size="4" face="arial"><b>'\ r'<td><font size="4" face="arial"><b>'
r'(.*?), (.*?),(.*?)</b></font></td>', re.IGNORECASE) r'(.*?), (.*?),(.*?)</b></font></td>', re.I)
_interregex = re.compile( _interregex = re.compile(
r'<td><font size="4" face="arial"><b>'\ r'<td><font size="4" face="arial"><b>'
r'([^,]+), ([^<]+)</b></font></td>', re.IGNORECASE) r'([^,]+), ([^<]+)</b></font></td>', re.I)
_condregex = re.compile( _condregex = re.compile(
r'<td width="100%" colspan="2" align="center"><strong>'\ r'<td width="100%" colspan="2" align="center"><strong>'
r'<font face="arial">([^<]+)</font></strong></td>', re.IGNORECASE) r'<font face="arial">([^<]+)</font></strong></td>', re.I)
_tempregex = re.compile( _tempregex = re.compile(
r'<td valign="top" align="right"><strong><font face="arial">'\ r'<td valign="top" align="right"><strong><font face="arial">'
r'([^<]+)</font></strong></td>', re.IGNORECASE) r'([^<]+)</font></strong></td>', re.I)
_chillregex = re.compile( _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) r'<small><font face="arial">([^<]+)</font></small></td>', re.I | re.S)
_heatregex = re.compile( _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) r'<small><font face="arial">([^<]+)</font></small></td>', re.I | re.S)
# States # States
_realStates = sets.Set(['ak', 'al', 'ar', 'az', 'ca', 'co', 'ct', _realStates = sets.Set(['ak', 'al', 'ar', 'az', 'ca', 'co', 'ct',
@ -124,16 +124,14 @@ class Weather(callbacks.Privmsg):
state = '' state = ''
if country in self._countryMap.keys(): if country in self._countryMap.keys():
country = self._countryMap[country] country = self._countryMap[country]
url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?'\ url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?' \
'pass=&dpp=&forecast=zandh&config=&'\ 'pass=&dpp=&forecast=zandh&config=&' \
'place=%s&state=%s&country=%s' % \ 'place=%s&state=%s&country=%s' % (city, state, country)
(city, state, country)
html = webutils.getUrl(url) html = webutils.getUrl(url)
if 'was not found' in html: if 'was not found' in html:
url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?'\ url = 'http://www.hamweather.net/cgi-bin/hw3/hw3.cgi?' \
'pass=&dpp=&forecast=zandh&config=&'\ 'pass=&dpp=&forecast=zandh&config=&' \
'place=%s&state=&country=%s' % \ 'place=%s&state=&country=%s' % (city, state)
(city, state)
html = webutils.getUrl(url) html = webutils.getUrl(url)
if 'was not found' in html: if 'was not found' in html:
irc.error('No such location could be found.') irc.error('No such location could be found.')
@ -144,7 +142,7 @@ class Weather(callbacks.Privmsg):
zip = privmsgs.getArgs(args) zip = privmsgs.getArgs(args)
zip = zip.replace(',', '') zip = zip.replace(',', '')
zip = zip.lower().split() 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] 'config=&forecast=zandh&pands=%s&Submit=GO' % args[0]
html = webutils.getUrl(url) html = webutils.getUrl(url)
if 'was not found' in html: if 'was not found' in html:

View File

@ -184,7 +184,7 @@ class Words(callbacks.Privmsg, configurable.Mixin):
return return
else: else:
addWord(self.dbHandler.getDb(), word, commit=True) addWord(self.dbHandler.getDb(), word, commit=True)
irc.reply(msg, conf.replySuccess) irc.replySuccess()
def crossword(self, irc, msg, args): def crossword(self, irc, msg, args):
"""<word> """<word>

View File

@ -141,7 +141,7 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
to protect the secrecy of secret channels. to protect the secrecy of secret channels.
""" """
if ircutils.isChannel(msg.args[0]): if ircutils.isChannel(msg.args[0]):
irc.error(conf.replyRequiresPrivacy) irc.errorRequiresPrivacy()
return return
L = irc.state.channels.keys() L = irc.state.channels.keys()
if L: if L:

View File

@ -147,7 +147,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
if len(ambiguousCommands) == 1: # Common case. if len(ambiguousCommands) == 1: # Common case.
(command, names) = ambiguousCommands.popitem() (command, names) = ambiguousCommands.popitem()
names.sort() 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 ' \ 'Please specify the plugin whose command you ' \
'wish to call by using its name as a command ' \ 'wish to call by using its name as a command ' \
'before calling it.' % \ 'before calling it.' % \
@ -160,7 +160,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
'plugins' % 'plugins' %
(command, utils.commaAndify(names))) (command, utils.commaAndify(names)))
s = '%s; please specify from which plugins to ' \ s = '%s; please specify from which plugins to ' \
'call these commands.' % '; '.join(L) 'call these commands.' % '; '.join(L)
irc.queueMsg(callbacks.error(msg, s)) irc.queueMsg(callbacks.error(msg, s))
else: else:
callbacks.IrcObjectProxy(irc, msg, tokens) callbacks.IrcObjectProxy(irc, msg, tokens)

View File

@ -286,7 +286,7 @@ class User(callbacks.Privmsg):
specified, returns the hostmasks of the user calling the command. specified, returns the hostmasks of the user calling the command.
""" """
if ircutils.isChannel(msg.args[0]): if ircutils.isChannel(msg.args[0]):
irc.error(conf.replyRequiresPrivacy) irc.errorRequiresPrivacy()
return return
name = privmsgs.getArgs(args, required=0, optional=1) name = privmsgs.getArgs(args, required=0, optional=1)
try: try:

View File

@ -299,15 +299,17 @@ class RichReplyMethods(object):
def replySuccess(self, s='', **kwargs): def replySuccess(self, s='', **kwargs):
self.reply(self._makeReply(conf.replySuccess, 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): def replyError(self, s='', **kwargs):
self.reply(self._makeReply(conf.replyError, s), **kwargs) self.reply(self._makeReply(conf.replyError, s), **kwargs)
def errorNoCapability(self, capability, s='', **kwargs): def errorNoCapability(self, capability, s='', **kwargs):
self.error(self._makeReply(conf.replyNoCapability % s, 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): def errorNotRegistered(self, s='', **kwargs):
self.error(self._makeReply(conf.replyNotRegistered, s), **kwargs) self.error(self._makeReply(conf.replyNotRegistered, s), **kwargs)

View File

@ -211,8 +211,8 @@ class IrcUser(object):
self.hostmasks = hostmasks self.hostmasks = hostmasks
def __repr__(self): def __repr__(self):
return '%s(ignore=%s, password=%r, name=%r, hashed=%r, '\ return '%s(ignore=%s, password=%r, name=%r, hashed=%r, ' \
'capabilities=%r, hostmasks=%r, secure=%r)\n' %\ 'capabilities=%r, hostmasks=%r, secure=%r)\n' % \
(self.__class__.__name__, (self.__class__.__name__,
self.ignore, self.password, self.name, self.hashed, self.ignore, self.password, self.name, self.hashed,
self.capabilities, self.hostmasks, self.secure) self.capabilities, self.hostmasks, self.secure)
@ -308,8 +308,8 @@ class IrcChannel(object):
self.lobotomized = lobotomized self.lobotomized = lobotomized
def __repr__(self): def __repr__(self):
return '%s(bans=%r, ignores=%r, capabilities=%r, '\ return '%s(bans=%r, ignores=%r, capabilities=%r, ' \
'lobotomized=%r, defaultAllow=%s)\n' %\ 'lobotomized=%r, defaultAllow=%s)\n' % \
(self.__class__.__name__, self.bans, self.ignores, (self.__class__.__name__, self.bans, self.ignores,
self.capabilities, self.lobotomized, self.capabilities, self.lobotomized,
self.defaultAllow) self.defaultAllow)