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

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

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

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,7 +230,7 @@ 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)

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,7 +134,7 @@ 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]

View File

@ -268,9 +268,9 @@ 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):

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

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

View File

@ -65,7 +65,7 @@ def configure(onStart, afterConnect, advanced):
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):
@ -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

@ -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+(.*)$"
@ -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

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

@ -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,8 +104,8 @@ 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)
@ -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,8 +235,8 @@ 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:

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

@ -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',
@ -126,14 +126,12 @@ class Weather(callbacks.Privmsg):
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.')

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

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