Reverted accidental commit.

This commit is contained in:
Jeremy Fincher 2004-09-17 05:09:14 +00:00
parent 0a2802f56e
commit f8a6f2c95d
10 changed files with 57 additions and 32 deletions

View File

@ -275,7 +275,8 @@ class Debian(callbacks.Privmsg,
r = utils.perlReToPythonRe(arg)
predicates.append(r.search)
except ValueError:
irc.errorInvalid('regular expression', arg, Raise=True)
irc.error('%r is not a valid regexp.' % arg)
return
elif option == '--arch':
arg = '_%s.' % arg
archPredicate = lambda s, arg=arg: (arg in s)

View File

@ -194,7 +194,8 @@ class Dunno(callbacks.Privmsg):
try:
id = int(id)
except ValueError:
irc.error('id', id, Raise=True)
irc.error('Invalid id: %r' % id)
return
dunno = self.db.get(channel, id)
if by != dunno.by:
cap = ircdb.makeChannelCapability(channel, 'op')
@ -237,7 +238,8 @@ class Dunno(callbacks.Privmsg):
try:
id = int(id)
except ValueError:
irc.errorInvalid('dunno id', id, Raise=True)
irc.error('%r is not a valid dunno id.' % id)
return
try:
dunno = self.db.get(channel, id)
name = ircdb.users.getUser(dunno.by).name
@ -266,15 +268,18 @@ class Dunno(callbacks.Privmsg):
try:
id = int(id)
except ValueError:
irc.errorInvalid('dunno id', id, Raise=True)
irc.error('%r is not a valid dunno id.' % id)
return
try:
_ = self.db.get(channel, id)
except KeyError:
irc.error('There is no dunno #%s.' % id)
return
try:
replacer = utils.perlReToReplacer(regexp)
except:
irc.errorInvalid('regular expression', regexp, Raise=True)
irc.error('%r is not a valid regular expression.' % regexp)
return
self.db.change(channel, id, replacer)
irc.replySuccess()

View File

@ -171,7 +171,8 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
try:
irc.reply(factoids[number-1])
except IndexError:
irc.errorInvalid('number for that key', number, Raise=True)
irc.error('That\'s not a valid number for that key.')
return
else:
intro = self.registryValue('factoidPrefix', channel)
prefix = '%r %s' % (key, intro)
@ -213,7 +214,8 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
try:
number = int(number)
except ValueError:
irc.errorInvalid('number', number, Raise=True)
irc.error('%s is not a valid number.' % number)
return
else:
number = 0
factoids = self._lookupFactoid(channel, key)
@ -291,7 +293,8 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
try:
(_, id) = results[number]
except IndexError:
irc.errorInvalid('factoid number', number, Raise=True)
irc.error('Invalid factoid number.')
return
cursor.execute("DELETE FROM factoids WHERE id=%s", id)
db.commit()
irc.replySuccess()
@ -367,13 +370,15 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
try:
replacer = utils.perlReToReplacer(regexp)
except ValueError, e:
irc.errorInvalid('regular expression', regexp, str(e), Raise=True)
irc.error('Invalid regexp: %s' % e)
return
try:
number = int(number)
if number <= 0:
raise ValueError
except ValueError:
irc.errorInvalid('id', number, Raise=True)
irc.error('Invalid key id.')
return
db = self.getDb(channel)
cursor = db.cursor()
cursor.execute("""SELECT factoids.id, factoids.fact

View File

@ -252,7 +252,8 @@ class Herald(callbacks.Privmsg):
try:
changer = utils.perlReToReplacer(regexp)
except ValueError, e:
irc.errorInvalid('regular expression', regexp, str(e), Raise=True)
irc.error('That\'s not a valid regexp: %s.' % e)
return
s = self.db[channel, id]
newS = changer(s)
self.db[channel, id] = newS

View File

@ -133,7 +133,8 @@ class Lookup(callbacks.Privmsg):
name = privmsgs.getArgs(args)
name = callbacks.canonicalName(name)
if name not in self.lookupDomains:
irc.errorInvalid('lookup', name, Raise=True)
irc.error('That\'s not a valid lookup to remove.')
return
db = self.dbHandler.getDb()
cursor = db.cursor()
try:
@ -248,7 +249,9 @@ class Lookup(callbacks.Privmsg):
try:
r = utils.perlReToPythonRe(arg)
except ValueError, e:
irc.errorInvalid('regular expression', arg, Raise=True)
irc.error('%r is not a valid regular expression' %
arg)
return
def p(s, r=r):
return int(bool(r.search(s)))
db.create_function(predicateName, 1, p)

View File

@ -194,7 +194,7 @@ class Observer(callbacks.Privmsg):
"""
name = privmsgs.getArgs(args)
if name not in self.registryValue('observers'):
irc.errorInvalid('observer', name, Raise=True)
irc.error('That\'s not a valid observer.', Raise=True)
g = self.registryValue('observers.%s' % name, value=False)
regexp = g()
command = g.command()
@ -222,9 +222,8 @@ class Observer(callbacks.Privmsg):
probability = 1.0
(name, regexp, command) = privmsgs.getArgs(args, required=3)
if not registry.isValidRegistryName(name):
irc.errorInvalid('observer name', name,
'Please be sure there are no spaces in the name.',
Raise=True)
irc.error('That\'s not a valid observer name. Please be sure '
'there are no spaces in the name.', Raise=True)
registerObserver(name, regexp, command, probability)
irc.replySuccess()

View File

@ -323,7 +323,8 @@ class Quotes(callbacks.Privmsg):
try:
id = int(id)
except ValueError:
irc.errorInvalid('id', id, Raise=True)
irc.error('Invalid id: %r' % id)
return
try:
quote = self.db.get(channel, id)
irc.reply(str(quote))
@ -341,7 +342,7 @@ class Quotes(callbacks.Privmsg):
try:
id = int(id)
except ValueError:
irc.errorInvalid('id', id, Raise=True)
irc.error('That\'s not a valid id: %r' % id)
try:
self.db.remove(channel, id)
irc.replySuccess()

View File

@ -112,7 +112,9 @@ class Todo(callbacks.Privmsg):
try:
userid = ircdb.users.getUserId(arg)
except KeyError:
irc.errorInvalid('task or username', arg, Raise=True)
irc.error(
'%r is not a valid task id or username' % arg)
return
db = self.dbHandler.getDb()
cursor = db.cursor()
if not userid and not taskid:
@ -149,7 +151,8 @@ class Todo(callbacks.Privmsg):
cursor.execute("""SELECT userid,priority,added_at,task,active
FROM todo WHERE id = %s""", taskid)
if cursor.rowcount == 0:
irc.errorInvalid('task id', taskid, Raise=True)
irc.error('%r is not a valid task id' % taskid)
return
(userid, pri, added_at, task, active) = cursor.fetchone()
# Construct and return the reply
user = ircdb.users.getUser(userid)
@ -188,7 +191,8 @@ class Todo(callbacks.Privmsg):
try:
priority = int(arg)
except ValueError, e:
irc.errorInvalid('priority', arg, Raise=True)
irc.error('%r is an invalid priority' % arg)
return
text = privmsgs.getArgs(rest)
db = self.dbHandler.getDb()
cursor = db.cursor()
@ -268,7 +272,9 @@ class Todo(callbacks.Privmsg):
try:
r = utils.perlReToPythonRe(arg)
except ValueError, e:
irc.errorInvalid('regular expression', arg, Raise=True)
irc.error('%r is not a valid regular expression' %
arg)
return
def p(s, r=r):
return int(bool(r.search(s)))
db.create_function(predicateName, 1, p)
@ -331,17 +337,19 @@ class Todo(callbacks.Privmsg):
try:
replacer = utils.perlReToReplacer(regexp)
except ValueError:
irc.errorInvalid('regular expression', regexp, Raise=True)
irc.error('%r is not a valid regexp' % regexp)
return
db = self.dbHandler.getDb()
cursor = db.cursor()
cursor.execute("""SELECT task FROM todo
WHERE userid = %s AND id = %s
AND active = 1""", userid, taskid)
if cursor.rowcount == 0:
irc.errorInvalid('task id', taskid, Raise=True)
irc.error('%r is not a valid task id' % taskid)
return
newtext = replacer(cursor.fetchone()[0])
cursor.execute("""UPDATE todo SET task = %s WHERE id = %s""",
newtext, taskid)
cursor.execute("""UPDATE todo SET task = %s
WHERE id = %s""", newtext, taskid)
db.commit()
irc.replySuccess()

View File

@ -166,7 +166,7 @@ class Topic(callbacks.Privmsg):
n += len(topics)
return n
except (ValueError, IndexError):
irc.errorInvalid('topic number', n, Raise=True)
irc.error('That\'s not a valid topic number.', Raise=True)
def topic(self, irc, msg, args, channel):
"""[<channel>]
@ -308,12 +308,14 @@ class Topic(callbacks.Privmsg):
(number, regexp) = privmsgs.getArgs(args, required=2)
topics = self._splitTopic(irc.state.getTopic(channel), channel)
if not topics:
irc.error('There are no topics to change.', Raise=True)
irc.error('There are no topics to change.')
return
number = self._topicNumber(irc, number, topics=topics)
try:
replacer = utils.perlReToReplacer(regexp)
except ValueError, e:
irc.errorInvalid('regexp', regexp, Raise=True)
irc.error('The regexp wasn\'t valid: %s' % e)
return
topics[number] = replacer(topics[number])
self._sendTopics(irc, channel, topics)
change = privmsgs.channel(change)

View File

@ -303,10 +303,10 @@ class Words(callbacks.Privmsg):
else:
# User input an invalid character
if len(letter) == 1:
irc.errorInvalid('letter', letter, Raise=True)
irc.error('That is not a valid letter.')
# User input an invalid word (len(try) != len(hidden))
else:
irc.errorInvalid('word guess', letter, Raise=True)
irc.error('That is not a valid word guess.')
# Verify if the user won or lost
if game.guessed and game.tries > 0:
self._hangmanReply(irc, channel,