diff --git a/plugins/Alias.py b/plugins/Alias.py index 45401173d..b7f345d9b 100644 --- a/plugins/Alias.py +++ b/plugins/Alias.py @@ -105,7 +105,7 @@ def makeNewAlias(name, alias): tokens = callbacks.tokenize(alias) if not wildcard and biggestDollar or biggestAt: args = privmsgs.getArgs(args, - needed=biggestDollar, + required=biggestDollar, optional=biggestAt) # Gotta have a mutable sequence (for replace). if biggestDollar + biggestAt == 1: # We got a string, no tuple. @@ -242,7 +242,7 @@ class Alias(callbacks.Privmsg): format. Underscores can be used to represent arguments to the alias itself; for instance ... """ - (name, alias) = privmsgs.getArgs(args, needed=2) + (name, alias) = privmsgs.getArgs(args, required=2) try: self.addAlias(irc, name, alias) irc.reply(msg, conf.replySuccess) diff --git a/plugins/Babelfish.py b/plugins/Babelfish.py index 7c93a49cf..f5efb5a7b 100644 --- a/plugins/Babelfish.py +++ b/plugins/Babelfish.py @@ -69,7 +69,7 @@ class Babelfish(callbacks.Privmsg): Returns translated from into . """ - (fromLang, toLang, text) = privmsgs.getArgs(args, needed=3) + (fromLang, toLang, text) = privmsgs.getArgs(args, required=3) try: fromLang = self._abbrevs[fromLang.lower()] toLang = self._abbrevs[toLang.lower()] @@ -92,7 +92,7 @@ class Babelfish(callbacks.Privmsg): until it doesn't change anymore or 12 times, whichever is fewer. One of the languages must be English. """ - (fromLang, toLang, text) = privmsgs.getArgs(args, needed=3) + (fromLang, toLang, text) = privmsgs.getArgs(args, required=3) try: fromLang = self._abbrevs[fromLang.lower()] toLang = self._abbrevs[toLang.lower()] @@ -117,7 +117,7 @@ class Babelfish(callbacks.Privmsg): Returns a random language supported by babelfish. If is provided, will include English in the list of possible languages. """ - allowEnglish = privmsgs.getArgs(args, needed=0, optional=1) + allowEnglish = privmsgs.getArgs(args, required=0, optional=1) language = random.choice(babelfish.available_languages) while not allowEnglish and language == 'English': language = random.choice(babelfish.available_languages) diff --git a/plugins/Bugzilla.py b/plugins/Bugzilla.py index 2d6d73a7b..3c10b9e3e 100644 --- a/plugins/Bugzilla.py +++ b/plugins/Bugzilla.py @@ -118,7 +118,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): commands. is the common name for the bugzilla and will be listed with the bugzilla query. """ - (shorthand, url, description) = privmsgs.getArgs(args, needed=3) + (shorthand, url, description) = privmsgs.getArgs(args, required=3) cursor = self.db.cursor() cursor.execute("""INSERT INTO bugzillas VALUES (%s, %s, %s)""", shorthand, url, description) @@ -153,7 +153,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): List defined bugzillae. If is specified, list the information for that bugzilla. """ - shorthand = privmsgs.getArgs(args, needed=0, optional=1) + shorthand = privmsgs.getArgs(args, required=0, optional=1) if shorthand: cursor = self.db.cursor() cursor.execute("""SELECT url,description from bugzillas where @@ -205,7 +205,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): Look up bug in the bugzilla associated with . """ - (shorthand, num) = privmsgs.getArgs(args, needed=2) + (shorthand, num) = privmsgs.getArgs(args, required=2) cursor = self.db.cursor() cursor.execute("""SELECT url,description from bugzillas where shorthand = %s""", shorthand) diff --git a/plugins/ChannelDB.py b/plugins/ChannelDB.py index 3c50d1353..aef30b456 100644 --- a/plugins/ChannelDB.py +++ b/plugins/ChannelDB.py @@ -385,7 +385,7 @@ class ChannelDB(plugins.ChannelDBHandler, # Must be first (die). isn't given, it defaults to the user sending the command. """ channel = privmsgs.getChannel(msg, args) - name = privmsgs.getArgs(args, needed=0, optional=1) + name = privmsgs.getArgs(args, required=0, optional=1) if not name: try: id = ircdb.users.getUserId(msg.prefix) @@ -483,7 +483,7 @@ class ChannelDB(plugins.ChannelDBHandler, # Must be first (die). available for that word, do we assume it's .) """ channel = privmsgs.getChannel(msg, args) - (arg1, arg2) = privmsgs.getArgs(args, needed=0, optional=2) + (arg1, arg2) = privmsgs.getArgs(args, required=0, optional=2) db = self.getDb(channel) cursor = db.cursor() if not arg1 and not arg2: diff --git a/plugins/Dunno.py b/plugins/Dunno.py index 753437580..c1af8d3f6 100644 --- a/plugins/Dunno.py +++ b/plugins/Dunno.py @@ -99,7 +99,7 @@ class Dunno(callbacks.Privmsg): except KeyError: irc.error(msg, conf.replyNotRegistered) return - text = privmsgs.getArgs(args, needed=1) + text = privmsgs.getArgs(args, required=1) cursor = self.db.cursor() cursor.execute("""INSERT INTO dunnos VALUES(NULL, %s, %s, %s)""", @@ -118,7 +118,7 @@ class Dunno(callbacks.Privmsg): except KeyError: irc.error(msg, conf.replyNotRegistered) return - dunno_id = privmsgs.getArgs(args, needed=1) + dunno_id = privmsgs.getArgs(args, required=1) cursor = self.db.cursor() cursor.execute("""SELECT added_by, dunno FROM dunnos @@ -142,7 +142,7 @@ class Dunno(callbacks.Privmsg): Search for dunno containing the given text. Returns the ids of the dunnos with the text in them. """ - text = privmsgs.getArgs(args, needed=1) + text = privmsgs.getArgs(args, required=1) glob = "%" + text + "%" cursor = self.db.cursor() cursor.execute("""SELECT id FROM dunnos @@ -160,7 +160,7 @@ class Dunno(callbacks.Privmsg): Display the text of the dunno with the given id. """ - id = privmsgs.getArgs(args, needed=1) + id = privmsgs.getArgs(args, required=1) try: id = int(id) except ValueError: diff --git a/plugins/Enforcer.py b/plugins/Enforcer.py index 3580b2505..3fea64b98 100644 --- a/plugins/Enforcer.py +++ b/plugins/Enforcer.py @@ -84,7 +84,7 @@ class Enforcer(callbacks.Privmsg, plugins.Configurable): to in other bots as 'bitch mode.') It defaults to True. """ self.topics = {} - (chanserv, revenge) = privmsgs.getArgs(args, needed=0, optional=2) + (chanserv, revenge) = privmsgs.getArgs(args, required=0, optional=2) self.chanserv = chanserv or 'ChanServ' self.started = True revenge = revenge.capitalize() diff --git a/plugins/Factoids.py b/plugins/Factoids.py index 1a4cfcad3..75877b968 100644 --- a/plugins/Factoids.py +++ b/plugins/Factoids.py @@ -321,7 +321,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg): . """ channel = privmsgs.getChannel(msg, args) - (key, number, regexp) = privmsgs.getArgs(args, needed=3) + (key, number, regexp) = privmsgs.getArgs(args, required=3) try: replacer = utils.perlReToReplacer(regexp) except ValueError, e: diff --git a/plugins/Fun.py b/plugins/Fun.py index f06dcd448..69deff27b 100644 --- a/plugins/Fun.py +++ b/plugins/Fun.py @@ -85,7 +85,7 @@ class Fun(callbacks.Privmsg): given, unsets the outFilter. is only necessary if the message isn't sent in the channel itself. """ - command = privmsgs.getArgs(args, needed=0, optional=1) + command = privmsgs.getArgs(args, required=0, optional=1) if command: command = callbacks.canonicalName(command) if command in self._filterCommands: @@ -152,7 +152,7 @@ class Fun(callbacks.Privmsg): Converts from base the number """ - (base, number) = privmsgs.getArgs(args, needed=2) + (base, number) = privmsgs.getArgs(args, required=2) irc.reply(msg, str(long(number, int(base)))) def binary(self, irc, msg, args): @@ -186,7 +186,7 @@ class Fun(callbacks.Privmsg): available in the documentation of the Python codecs module: . """ - encoding, text = privmsgs.getArgs(args, needed=2) + encoding, text = privmsgs.getArgs(args, required=2) irc.reply(msg, text.encode(encoding)) def decode(self, irc, msg, args): @@ -196,7 +196,7 @@ class Fun(callbacks.Privmsg): available in the documentation of the Python codecs module: . """ - encoding, text = privmsgs.getArgs(args, needed=2) + encoding, text = privmsgs.getArgs(args, required=2) irc.reply(msg, text.decode(encoding).encode('utf-8')) def hexlify(self, irc, msg, args): @@ -410,7 +410,7 @@ class Fun(callbacks.Privmsg): Returns the levenshtein distance (also known as the "edit distance" between and """ - (s1, s2) = privmsgs.getArgs(args, needed=2) + (s1, s2) = privmsgs.getArgs(args, required=2) irc.reply(msg, str(utils.distance(s1, s2))) def soundex(self, irc, msg, args): diff --git a/plugins/FunDB.py b/plugins/FunDB.py index 054fe8cbe..5fbb8ef2d 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -184,7 +184,7 @@ class FunDB(callbacks.Privmsg): Gives you a standard, random BOFH excuse or the excuse with the given . """ - id = privmsgs.getArgs(args, needed=0, optional=1) + id = privmsgs.getArgs(args, required=0, optional=1) cursor = self.db.cursor() if id: try: @@ -218,7 +218,7 @@ class FunDB(callbacks.Privmsg): when it used that lart against, say, jemfinch, to say '/me slices jemfinch in half with a free AOL cd' """ - (table, s) = privmsgs.getArgs(args, needed=2) + (table, s) = privmsgs.getArgs(args, required=2) table = table.lower() try: name = ircdb.users.getUser(msg.prefix).name @@ -250,7 +250,7 @@ class FunDB(callbacks.Privmsg): Removes the data, referred to in the first argument, with the id number from the database. """ - (table, id) = privmsgs.getArgs(args, needed=2) + (table, id) = privmsgs.getArgs(args, required=2) table = table.lower() try: ircdb.users.getUser(msg.prefix).name @@ -280,7 +280,7 @@ class FunDB(callbacks.Privmsg): zero-based index into the db; is a regular expression of the form s/regexp/replacement/flags. """ - (table, id, regexp) = privmsgs.getArgs(args, needed=3) + (table, id, regexp) = privmsgs.getArgs(args, required=3) table = table.lower() try: name = ircdb.users.getUser(msg.prefix).name @@ -341,7 +341,7 @@ class FunDB(callbacks.Privmsg): Gets the record with id from the table specified. """ - (table, id) = privmsgs.getArgs(args, needed=2) + (table, id) = privmsgs.getArgs(args, required=2) table = table.lower() try: id = int(id) @@ -366,7 +366,7 @@ class FunDB(callbacks.Privmsg): Gets the info for the record with id from the table specified. """ - (table, id) = privmsgs.getArgs(args, needed=2) + (table, id) = privmsgs.getArgs(args, required=2) table = table.lower() try: id = int(id) diff --git a/plugins/Lookup.py b/plugins/Lookup.py index eb815faf7..a67049b93 100644 --- a/plugins/Lookup.py +++ b/plugins/Lookup.py @@ -113,7 +113,7 @@ class Lookup(callbacks.Privmsg): for in conf.dataDir. Use 'lookup ' to get the value of the key in the file. """ - (name, filename) = privmsgs.getArgs(args, needed=2) + (name, filename) = privmsgs.getArgs(args, required=2) db = getDb() cursor = db.cursor() try: diff --git a/plugins/Math.py b/plugins/Math.py index ce1184a2d..bb6035338 100644 --- a/plugins/Math.py +++ b/plugins/Math.py @@ -213,7 +213,7 @@ class Math(callbacks.Privmsg): n = args.pop(0) else: n = 1 - (unit1, to, unit2) = privmsgs.getArgs(args, needed=3) + (unit1, to, unit2) = privmsgs.getArgs(args, required=3) if to != 'to': raise callbacks.ArgumentError try: diff --git a/plugins/MoobotFactoids.py b/plugins/MoobotFactoids.py index 43f1627df..001512e2d 100644 --- a/plugins/MoobotFactoids.py +++ b/plugins/MoobotFactoids.py @@ -368,7 +368,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): Returns the literal factoid for the given factoid key. No parsing of the factoid value is done as it is with normal retrieval. """ - key = privmsgs.getArgs(args, needed=1) + key = privmsgs.getArgs(args, required=1) cursor = self.db.cursor() cursor.execute("""SELECT fact FROM factoids WHERE key LIKE %s""", key) if cursor.rowcount == 0: @@ -383,7 +383,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): Returns the various bits of info on the factoid for the given key. """ - key = privmsgs.getArgs(args, needed=1) + key = privmsgs.getArgs(args, required=1) # Start building the response string s = key + ": " # Next, get all the info and build the response piece by piece @@ -433,7 +433,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): except KeyError: irc.error(msg, conf.replyNotRegistered) return - key = privmsgs.getArgs(args, needed=1) + key = privmsgs.getArgs(args, required=1) cursor = self.db.cursor() cursor.execute("""SELECT created_by, locked_by FROM factoids WHERE key LIKE %s""", key) @@ -545,7 +545,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): author has an integer name, you'll have to use that author's id to use this function (so don't use integer usernames!). """ - author = privmsgs.getArgs(args, needed=1) + author = privmsgs.getArgs(args, required=1) try: id = ircdb.users.getUserId(author) except KeyError: @@ -568,7 +568,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): Lists the keys of the factoids whose key contains the provided text. """ - search = privmsgs.getArgs(args, needed=1) + search = privmsgs.getArgs(args, required=1) glob = '%' + search + '%' cursor = self.db.cursor() cursor.execute("""SELECT key FROM factoids @@ -588,7 +588,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): Lists the keys of the factoids whose value contains the provided text. """ - search = privmsgs.getArgs(args, needed=1) + search = privmsgs.getArgs(args, required=1) glob = '%' + search + '%' cursor = self.db.cursor() cursor.execute("""SELECT key FROM factoids @@ -614,7 +614,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp): except KeyError: irc.error(msg, conf.replyNotRegistered) return - key = privmsgs.getArgs(args, needed=1) + key = privmsgs.getArgs(args, required=1) cursor = self.db.cursor() cursor.execute("""SELECT key, locked_at FROM factoids WHERE key LIKE %s""", key) diff --git a/plugins/News.py b/plugins/News.py index c7b5a6bef..336f57dff 100644 --- a/plugins/News.py +++ b/plugins/News.py @@ -153,7 +153,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg): in the channel itself. """ channel = privmsgs.getChannel(msg, args) - number = privmsgs.getArgs(args, needed=0, optional=1) + number = privmsgs.getArgs(args, required=0, optional=1) if number: self._readnews(irc, msg, [channel, number]) return @@ -195,7 +195,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg): s/text/replacement/flags. is only necessary if the message isn't sent on the channel itself. """ - (id, regexp) = privmsgs.getArgs(args, needed=2) + (id, regexp) = privmsgs.getArgs(args, required=2) try: replacer = utils.perlReToReplacer(regexp) except ValueError, e: @@ -224,7 +224,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg): is only necessary if the message isn't sent in the channel itself. """ channel = privmsgs.getChannel(msg, args) - id = privmsgs.getArgs(args, needed=0, optional=1) + id = privmsgs.getArgs(args, required=0, optional=1) db = self.getDb(channel) cursor = db.cursor() if id: diff --git a/plugins/Note.py b/plugins/Note.py index 370f87a53..728698625 100644 --- a/plugins/Note.py +++ b/plugins/Note.py @@ -114,7 +114,7 @@ class Note(callbacks.Privmsg): Sends a new note to the user specified. """ - (name, note) = privmsgs.getArgs(args, needed=2) + (name, note) = privmsgs.getArgs(args, required=2) if ircdb.users.hasUser(name): toId = ircdb.users.getUserId(name) else: diff --git a/plugins/Poll.py b/plugins/Poll.py index 47b0a9741..8e363142f 100644 --- a/plugins/Poll.py +++ b/plugins/Poll.py @@ -179,7 +179,7 @@ class Poll(callbacks.Privmsg): Vote yes or no on an active poll with the given id. This command can also be used to override the previous vote. """ - (id, vote) = privmsgs.getArgs(args, needed=2) + (id, vote) = privmsgs.getArgs(args, required=2) try: id = int(id) except ValueError: diff --git a/plugins/Relay.py b/plugins/Relay.py index 46d2b75fc..617d8c04a 100644 --- a/plugins/Relay.py +++ b/plugins/Relay.py @@ -167,7 +167,7 @@ class Relay(callbacks.Privmsg, plugins.Configurable): if not self.started: irc.error(msg, 'You must use the start command first.') return - abbreviation, server = privmsgs.getArgs(args, needed=2) + abbreviation, server = privmsgs.getArgs(args, required=2) if isinstance(irc, irclib.Irc): realIrc = irc else: diff --git a/plugins/Services.py b/plugins/Services.py index 05f5a28ab..491eea42c 100644 --- a/plugins/Services.py +++ b/plugins/Services.py @@ -78,7 +78,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg): irc.error(msg, conf.replyRequiresPrivacy) return (self.nick, self.password, nickserv, chanserv) = \ - privmsgs.getArgs(args, needed=2, optional=2) + privmsgs.getArgs(args, required=2, optional=2) self.nick = ircutils.IrcString(self.nick) self.nickserv = ircutils.IrcString(nickserv or 'NickServ') self.chanserv = ircutils.IrcString(chanserv or 'ChanServ') diff --git a/plugins/Sourceforge.py b/plugins/Sourceforge.py index 75f347c72..fbc57c505 100644 --- a/plugins/Sourceforge.py +++ b/plugins/Sourceforge.py @@ -177,7 +177,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): Returns a list of the most recent bugs filed against . Defaults to searching for bugs in the project set by defaultproject. """ - project = privmsgs.getArgs(args, needed=0, optional=1) + project = privmsgs.getArgs(args, required=0, optional=1) if not project: project = self.configurables.get('default-project', msg.args[0]) if not project: @@ -221,7 +221,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): Returns a list of the most recent RFEs filed against . Defaults to searching for RFEs in the project set by defaultproject. """ - project = privmsgs.getArgs(args, needed=0, optional=1) + project = privmsgs.getArgs(args, required=0, optional=1) if not project: project = self.configurables.get('default-project', msg.args[0]) if not project: diff --git a/plugins/Todo.py b/plugins/Todo.py index 0240d3f32..a32857dd4 100644 --- a/plugins/Todo.py +++ b/plugins/Todo.py @@ -95,7 +95,7 @@ class Todo(callbacks.Privmsg): will return a list of task ids that that user has added to their todo list. """ - arg = privmsgs.getArgs(args, needed=0, optional=1) + arg = privmsgs.getArgs(args, required=0, optional=1) userid = None taskid = None @@ -186,7 +186,7 @@ class Todo(callbacks.Privmsg): except ValueError, e: irc.error(msg, '%r is an invalid priority' % arg) return - text = privmsgs.getArgs(rest, needed=1) + text = privmsgs.getArgs(rest, required=1) cursor = self.db.cursor() cursor.execute("""INSERT INTO todo VALUES (NULL, %s, %s, %s, %s, 1)""", @@ -205,7 +205,7 @@ class Todo(callbacks.Privmsg): irc.error(msg, conf.replyNotRegistered) return - taskid = privmsgs.getArgs(args, needed=1) + taskid = privmsgs.getArgs(args, required=1) cursor = self.db.cursor() cursor.execute("""SELECT * FROM todo WHERE id = %s AND userid = %s @@ -277,7 +277,7 @@ class Todo(callbacks.Privmsg): except KeyError: irc.error(msg, conf.replyNotRegistered) return - (id, priority) = privmsgs.getArgs(args, needed=2) + (id, priority) = privmsgs.getArgs(args, required=2) cursor = self.db.cursor() cursor.execute("""SELECT userid, priority FROM todo WHERE id = %s AND active = 1""", id) @@ -304,7 +304,7 @@ class Todo(callbacks.Privmsg): except KeyError: irc.error(msg, conf.replyNotRegistered) return - taskid, regexp = privmsgs.getArgs(args, needed=2) + taskid, regexp = privmsgs.getArgs(args, required=2) # Check the regexp first, it's easier and doesn't require a db query try: replacer = utils.perlReToReplacer(regexp) diff --git a/plugins/Topic.py b/plugins/Topic.py index b42e78a13..a75103cec 100644 --- a/plugins/Topic.py +++ b/plugins/Topic.py @@ -138,7 +138,7 @@ class Topic(callbacks.Privmsg): s/regexp/replacement/flags. is only necessary if the message isn't sent in the channel itself. """ - (number, regexp) = privmsgs.getArgs(args, needed=2) + (number, regexp) = privmsgs.getArgs(args, required=2) try: number = int(number) if number > 0: diff --git a/plugins/Utilities.py b/plugins/Utilities.py index 2562b38c6..90c929a3d 100644 --- a/plugins/Utilities.py +++ b/plugins/Utilities.py @@ -71,7 +71,7 @@ class Utilities(callbacks.Privmsg): . The first and second arguments must necessarily be the same length. """ - (bad, good, text) = privmsgs.getArgs(args, needed=3) + (bad, good, text) = privmsgs.getArgs(args, required=3) irc.reply(msg, text.translate(string.maketrans(bad, good))) def strupper(self, irc, msg, args): @@ -114,7 +114,7 @@ class Utilities(callbacks.Privmsg): thing as strjoin "", since if contains spaces, they won't be removed by strconcat. """ - (first, second) = privmsgs.getArgs(args, needed=2) + (first, second) = privmsgs.getArgs(args, required=2) irc.reply(msg, first+second) def echo(self, irc, msg, args): @@ -134,7 +134,7 @@ class Utilities(callbacks.Privmsg): s/regexp/replacement/flags, returns the result of applying such a regexp to """ - (regexp, text) = privmsgs.getArgs(args, needed=2) + (regexp, text) = privmsgs.getArgs(args, required=2) f = None try: r = utils.perlReToPythonRe(regexp) diff --git a/src/Channel.py b/src/Channel.py index 51d9fe05c..78f840dae 100755 --- a/src/Channel.py +++ b/src/Channel.py @@ -94,7 +94,7 @@ class Channel(callbacks.Privmsg): this will cause the bot to "cycle", or PART and then JOIN the channel. If is given, join the channel using that key. """ - key = privmsgs.getArgs(args, needed=0, optional=1) + key = privmsgs.getArgs(args, required=0, optional=1) if not key: key = None irc.queueMsg(ircmsgs.part(channel)) @@ -249,7 +249,7 @@ class Channel(callbacks.Privmsg): The argument is only necessary if the message isn't being sent in the channel itself. """ - channelarg = privmsgs.getArgs(args, needed=0, optional=1) + channelarg = privmsgs.getArgs(args, required=0, optional=1) channel = channelarg or channel c = ircdb.channels.getChannel(channel) if len(c.ignores) == 0: diff --git a/src/Misc.py b/src/Misc.py index 1acd40924..cc3d3fb79 100755 --- a/src/Misc.py +++ b/src/Misc.py @@ -72,7 +72,7 @@ class Misc(callbacks.Privmsg): for (option, argument) in optlist: if option == '--private': evenPrivate = True - name = privmsgs.getArgs(rest, needed=0, optional=1) + name = privmsgs.getArgs(rest, required=0, optional=1) name = name.lower() if not name: names = [cb.name() for cb in irc.callbacks @@ -172,7 +172,7 @@ class Misc(callbacks.Privmsg): Returns the hostmask of . If isn't given, return the hostmask of the person giving the command. """ - nick = privmsgs.getArgs(args, needed=0, optional=1) + nick = privmsgs.getArgs(args, required=0, optional=1) try: if nick: irc.reply(msg, irc.state.nickToHostmask(nick)) @@ -201,7 +201,7 @@ class Misc(callbacks.Privmsg): Returns the size of the various logfiles in use. If given a specific logfile, returns only the size of that logfile. """ - filename = privmsgs.getArgs(args, needed=0, optional=1) + filename = privmsgs.getArgs(args, required=0, optional=1) if filename: if not filename.endswith('.log'): irc.error(msg, 'That filename doesn\'t appear to be a log.') @@ -243,7 +243,7 @@ class Misc(callbacks.Privmsg): If is given, it takes the continuation of the last command from instead of the person sending this message. """ - nick = privmsgs.getArgs(args, needed=0, optional=1) + nick = privmsgs.getArgs(args, required=0, optional=1) userHostmask = msg.prefix.split('!', 1)[1] if nick: try: @@ -330,7 +330,7 @@ class Misc(callbacks.Privmsg): Tells the whatever is. Use nested commands to your benefit here. """ - (target, text) = privmsgs.getArgs(args, needed=2) + (target, text) = privmsgs.getArgs(args, required=2) s = '%s wants me to tell you: %s' % (msg.nick, text) irc.queueMsg(ircmsgs.privmsg(target, s)) raise callbacks.CannotNest diff --git a/src/Owner.py b/src/Owner.py index 426988e3c..ec455104b 100644 --- a/src/Owner.py +++ b/src/Owner.py @@ -202,7 +202,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg): variable type with only the argument and sets the value of the variable to when both arguments are given. """ - (name, value) = privmsgs.getArgs(args, needed=0, optional=2) + (name, value) = privmsgs.getArgs(args, required=0, optional=2) if name and value: if conf.allowEval: try: diff --git a/src/User.py b/src/User.py index e7f6c0af7..a1dcb96d9 100755 --- a/src/User.py +++ b/src/User.py @@ -60,7 +60,7 @@ class User(callbacks.Privmsg): on disk, rather than being stored in plaintext. """ (optlist, rest) = getopt.getopt(args, '', ['hashed']) - (name, password) = privmsgs.getArgs(rest, needed=2) + (name, password) = privmsgs.getArgs(rest, required=2) hashed = False for (option, arg) in optlist: if option == '--hashed': @@ -94,7 +94,7 @@ class User(callbacks.Privmsg): Unregisters from the user database. """ - (name, password) = privmsgs.getArgs(args, needed=2) + (name, password) = privmsgs.getArgs(args, required=2) if not self._checkNotChannel(irc, msg, password): return try: @@ -117,7 +117,7 @@ class User(callbacks.Privmsg): If you include the parameter, this message must be sent to the bot privately (not on a channel). """ - (name, newname, password) = privmsgs.getArgs(args, needed=2,optional=1) + (name, newname, password) = privmsgs.getArgs(args, required=2,optional=1) if not self._checkNotChannel(irc, msg, password): return try: diff --git a/src/plugins.py b/src/plugins.py index 884d3fd4a..38d75ab97 100644 --- a/src/plugins.py +++ b/src/plugins.py @@ -312,7 +312,7 @@ class Configurable(object): if not ircdb.checkCapability(msg.prefix, capability): irc.error(msg, conf.replyNoCapability % capability) return - (name, value) = privmsgs.getArgs(args, needed=0, optional=2) + (name, value) = privmsgs.getArgs(args, required=0, optional=2) if not name: irc.reply(msg, utils.commaAndify(self.configurables.names())) return diff --git a/src/privmsgs.py b/src/privmsgs.py index e2da40e33..5a3b32f9f 100644 --- a/src/privmsgs.py +++ b/src/privmsgs.py @@ -58,22 +58,22 @@ def getChannel(msg, args): raise callbacks.Error, 'Command must be sent in a channel or ' \ 'include a channel in its arguments.' -def getArgs(args, needed=1, optional=0): - """Take the needed arguments from args. +def getArgs(args, required=1, optional=0): + """Take the required/optional arguments from args. - Always returns a list of size needed + optional, filling it with however + Always returns a list of size required + optional, filling it with however many empty strings is necessary to fill the tuple to the right size. - If there aren't enough args even to satisfy needed, raise an error and + If there aren't enough args even to satisfy required, raise an error and let the caller handle sending the help message. """ - if len(args) < needed: + if len(args) < required: raise callbacks.ArgumentError - if len(args) < needed + optional: - ret = list(args) + ([''] * (needed + optional - len(args))) - elif len(args) >= needed + optional: - ret = list(args[:needed + optional - 1]) - ret.append(' '.join(args[needed + optional - 1:])) + if len(args) < required + optional: + ret = list(args) + ([''] * (required + optional - len(args))) + elif len(args) >= required + optional: + ret = list(args[:required + optional - 1]) + ret.append(' '.join(args[required + optional - 1:])) if len(ret) == 1: return ret[0] else: diff --git a/test/test_privmsgs.py b/test/test_privmsgs.py index 6d11d73cc..b522744e9 100644 --- a/test/test_privmsgs.py +++ b/test/test_privmsgs.py @@ -52,14 +52,14 @@ class FunctionsTest(unittest.TestCase): def testGetArgs(self): args = ['foo', 'bar', 'baz'] self.assertEqual(privmsgs.getArgs(args), ' '.join(args)) - self.assertEqual(privmsgs.getArgs(args, needed=2), + self.assertEqual(privmsgs.getArgs(args, required=2), [args[0], ' '.join(args[1:])]) - self.assertEqual(privmsgs.getArgs(args, needed=3), args) + self.assertEqual(privmsgs.getArgs(args, required=3), args) self.assertRaises(callbacks.ArgumentError, - privmsgs.getArgs, args, needed=4) - self.assertEqual(privmsgs.getArgs(args, needed=3, optional=1), + privmsgs.getArgs, args, required=4) + self.assertEqual(privmsgs.getArgs(args, required=3, optional=1), args + ['']) - self.assertEqual(privmsgs.getArgs(args, needed=0, optional=1), + self.assertEqual(privmsgs.getArgs(args, required=0, optional=1), ' '.join(args))