From f8a6f2c95daed809f80fa1a61815aaf01ef4ff83 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 17 Sep 2004 05:09:14 +0000 Subject: [PATCH] Reverted accidental commit. --- plugins/Debian.py | 3 ++- plugins/Dunno.py | 13 +++++++++---- plugins/Factoids.py | 15 ++++++++++----- plugins/Herald.py | 3 ++- plugins/Lookup.py | 7 +++++-- plugins/Observer.py | 7 +++---- plugins/Quotes.py | 5 +++-- plugins/Todo.py | 24 ++++++++++++++++-------- plugins/Topic.py | 8 +++++--- plugins/Words.py | 4 ++-- 10 files changed, 57 insertions(+), 32 deletions(-) diff --git a/plugins/Debian.py b/plugins/Debian.py index 60e6a5a00..cad078043 100644 --- a/plugins/Debian.py +++ b/plugins/Debian.py @@ -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) diff --git a/plugins/Dunno.py b/plugins/Dunno.py index a158d5020..0eed0a633 100644 --- a/plugins/Dunno.py +++ b/plugins/Dunno.py @@ -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() diff --git a/plugins/Factoids.py b/plugins/Factoids.py index 74e6a7843..6100a1941 100644 --- a/plugins/Factoids.py +++ b/plugins/Factoids.py @@ -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 diff --git a/plugins/Herald.py b/plugins/Herald.py index 68f36bf7a..51130bd06 100644 --- a/plugins/Herald.py +++ b/plugins/Herald.py @@ -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 diff --git a/plugins/Lookup.py b/plugins/Lookup.py index 2463a405e..f75805685 100644 --- a/plugins/Lookup.py +++ b/plugins/Lookup.py @@ -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) diff --git a/plugins/Observer.py b/plugins/Observer.py index 027845b03..be83cbe87 100644 --- a/plugins/Observer.py +++ b/plugins/Observer.py @@ -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() diff --git a/plugins/Quotes.py b/plugins/Quotes.py index 43c6ab2c4..e9c3c54fd 100644 --- a/plugins/Quotes.py +++ b/plugins/Quotes.py @@ -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() diff --git a/plugins/Todo.py b/plugins/Todo.py index 03784c6c5..5c4b4867c 100644 --- a/plugins/Todo.py +++ b/plugins/Todo.py @@ -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() diff --git a/plugins/Topic.py b/plugins/Topic.py index 3146526af..772c2d51d 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -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): """[] @@ -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) diff --git a/plugins/Words.py b/plugins/Words.py index 88c26d332..f74d881a1 100644 --- a/plugins/Words.py +++ b/plugins/Words.py @@ -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,