mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Changed the needed= keyword arg in privmsgs.getArgs to required=.
This commit is contained in:
parent
86e2110010
commit
2e0b225d0c
@ -105,7 +105,7 @@ def makeNewAlias(name, alias):
|
|||||||
tokens = callbacks.tokenize(alias)
|
tokens = callbacks.tokenize(alias)
|
||||||
if not wildcard and biggestDollar or biggestAt:
|
if not wildcard and biggestDollar or biggestAt:
|
||||||
args = privmsgs.getArgs(args,
|
args = privmsgs.getArgs(args,
|
||||||
needed=biggestDollar,
|
required=biggestDollar,
|
||||||
optional=biggestAt)
|
optional=biggestAt)
|
||||||
# Gotta have a mutable sequence (for replace).
|
# Gotta have a mutable sequence (for replace).
|
||||||
if biggestDollar + biggestAt == 1: # We got a string, no tuple.
|
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
|
format. Underscores can be used to represent arguments to the alias
|
||||||
itself; for instance ...
|
itself; for instance ...
|
||||||
"""
|
"""
|
||||||
(name, alias) = privmsgs.getArgs(args, needed=2)
|
(name, alias) = privmsgs.getArgs(args, required=2)
|
||||||
try:
|
try:
|
||||||
self.addAlias(irc, name, alias)
|
self.addAlias(irc, name, alias)
|
||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
@ -69,7 +69,7 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
|
|
||||||
Returns <text> translated from <from-language> into <to-language>.
|
Returns <text> translated from <from-language> into <to-language>.
|
||||||
"""
|
"""
|
||||||
(fromLang, toLang, text) = privmsgs.getArgs(args, needed=3)
|
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
||||||
try:
|
try:
|
||||||
fromLang = self._abbrevs[fromLang.lower()]
|
fromLang = self._abbrevs[fromLang.lower()]
|
||||||
toLang = self._abbrevs[toLang.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
|
until it doesn't change anymore or 12 times, whichever is fewer. One
|
||||||
of the languages must be English.
|
of the languages must be English.
|
||||||
"""
|
"""
|
||||||
(fromLang, toLang, text) = privmsgs.getArgs(args, needed=3)
|
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
||||||
try:
|
try:
|
||||||
fromLang = self._abbrevs[fromLang.lower()]
|
fromLang = self._abbrevs[fromLang.lower()]
|
||||||
toLang = self._abbrevs[toLang.lower()]
|
toLang = self._abbrevs[toLang.lower()]
|
||||||
@ -117,7 +117,7 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
Returns a random language supported by babelfish. If <allow-english>
|
Returns a random language supported by babelfish. If <allow-english>
|
||||||
is provided, will include English in the list of possible languages.
|
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)
|
language = random.choice(babelfish.available_languages)
|
||||||
while not allowEnglish and language == 'English':
|
while not allowEnglish and language == 'English':
|
||||||
language = random.choice(babelfish.available_languages)
|
language = random.choice(babelfish.available_languages)
|
||||||
|
@ -118,7 +118,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
|
|||||||
commands. <description> is the common name for the bugzilla and will
|
commands. <description> is the common name for the bugzilla and will
|
||||||
be listed with the bugzilla query.
|
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 = self.db.cursor()
|
||||||
cursor.execute("""INSERT INTO bugzillas VALUES (%s, %s, %s)""",
|
cursor.execute("""INSERT INTO bugzillas VALUES (%s, %s, %s)""",
|
||||||
shorthand, url, description)
|
shorthand, url, description)
|
||||||
@ -153,7 +153,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
|
|||||||
List defined bugzillae. If <abbreviation> is specified, list the
|
List defined bugzillae. If <abbreviation> is specified, list the
|
||||||
information for that bugzilla.
|
information for that bugzilla.
|
||||||
"""
|
"""
|
||||||
shorthand = privmsgs.getArgs(args, needed=0, optional=1)
|
shorthand = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
if shorthand:
|
if shorthand:
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT url,description from bugzillas where
|
cursor.execute("""SELECT url,description from bugzillas where
|
||||||
@ -205,7 +205,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
|
|||||||
|
|
||||||
Look up bug <number> in the bugzilla associated with <abbreviation>.
|
Look up bug <number> in the bugzilla associated with <abbreviation>.
|
||||||
"""
|
"""
|
||||||
(shorthand, num) = privmsgs.getArgs(args, needed=2)
|
(shorthand, num) = privmsgs.getArgs(args, required=2)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT url,description from bugzillas where
|
cursor.execute("""SELECT url,description from bugzillas where
|
||||||
shorthand = %s""", shorthand)
|
shorthand = %s""", shorthand)
|
||||||
|
@ -385,7 +385,7 @@ class ChannelDB(plugins.ChannelDBHandler, # Must be first (die).
|
|||||||
isn't given, it defaults to the user sending the command.
|
isn't given, it defaults to the user sending the command.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
name = privmsgs.getArgs(args, needed=0, optional=1)
|
name = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
if not name:
|
if not name:
|
||||||
try:
|
try:
|
||||||
id = ircdb.users.getUserId(msg.prefix)
|
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 <user>.)
|
available for that word, do we assume it's <user>.)
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
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)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
if not arg1 and not arg2:
|
if not arg1 and not arg2:
|
||||||
|
@ -99,7 +99,7 @@ class Dunno(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(msg, conf.replyNotRegistered)
|
irc.error(msg, conf.replyNotRegistered)
|
||||||
return
|
return
|
||||||
text = privmsgs.getArgs(args, needed=1)
|
text = privmsgs.getArgs(args, required=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""INSERT INTO dunnos
|
cursor.execute("""INSERT INTO dunnos
|
||||||
VALUES(NULL, %s, %s, %s)""",
|
VALUES(NULL, %s, %s, %s)""",
|
||||||
@ -118,7 +118,7 @@ class Dunno(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(msg, conf.replyNotRegistered)
|
irc.error(msg, conf.replyNotRegistered)
|
||||||
return
|
return
|
||||||
dunno_id = privmsgs.getArgs(args, needed=1)
|
dunno_id = privmsgs.getArgs(args, required=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT added_by, dunno
|
cursor.execute("""SELECT added_by, dunno
|
||||||
FROM dunnos
|
FROM dunnos
|
||||||
@ -142,7 +142,7 @@ class Dunno(callbacks.Privmsg):
|
|||||||
Search for dunno containing the given text. Returns the ids of the
|
Search for dunno containing the given text. Returns the ids of the
|
||||||
dunnos with the text in them.
|
dunnos with the text in them.
|
||||||
"""
|
"""
|
||||||
text = privmsgs.getArgs(args, needed=1)
|
text = privmsgs.getArgs(args, required=1)
|
||||||
glob = "%" + text + "%"
|
glob = "%" + text + "%"
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT id FROM dunnos
|
cursor.execute("""SELECT id FROM dunnos
|
||||||
@ -160,7 +160,7 @@ class Dunno(callbacks.Privmsg):
|
|||||||
|
|
||||||
Display the text of the dunno with the given id.
|
Display the text of the dunno with the given id.
|
||||||
"""
|
"""
|
||||||
id = privmsgs.getArgs(args, needed=1)
|
id = privmsgs.getArgs(args, required=1)
|
||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -84,7 +84,7 @@ class Enforcer(callbacks.Privmsg, plugins.Configurable):
|
|||||||
to in other bots as 'bitch mode.') It defaults to True.
|
to in other bots as 'bitch mode.') It defaults to True.
|
||||||
"""
|
"""
|
||||||
self.topics = {}
|
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.chanserv = chanserv or 'ChanServ'
|
||||||
self.started = True
|
self.started = True
|
||||||
revenge = revenge.capitalize()
|
revenge = revenge.capitalize()
|
||||||
|
@ -321,7 +321,7 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
<regexp>.
|
<regexp>.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
(key, number, regexp) = privmsgs.getArgs(args, needed=3)
|
(key, number, regexp) = privmsgs.getArgs(args, required=3)
|
||||||
try:
|
try:
|
||||||
replacer = utils.perlReToReplacer(regexp)
|
replacer = utils.perlReToReplacer(regexp)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
|
@ -85,7 +85,7 @@ class Fun(callbacks.Privmsg):
|
|||||||
given, unsets the outFilter. <channel> is only necessary if the
|
given, unsets the outFilter. <channel> is only necessary if the
|
||||||
message isn't sent in the channel itself.
|
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:
|
if command:
|
||||||
command = callbacks.canonicalName(command)
|
command = callbacks.canonicalName(command)
|
||||||
if command in self._filterCommands:
|
if command in self._filterCommands:
|
||||||
@ -152,7 +152,7 @@ class Fun(callbacks.Privmsg):
|
|||||||
|
|
||||||
Converts from base <base> the number <number>
|
Converts from base <base> the number <number>
|
||||||
"""
|
"""
|
||||||
(base, number) = privmsgs.getArgs(args, needed=2)
|
(base, number) = privmsgs.getArgs(args, required=2)
|
||||||
irc.reply(msg, str(long(number, int(base))))
|
irc.reply(msg, str(long(number, int(base))))
|
||||||
|
|
||||||
def binary(self, irc, msg, args):
|
def binary(self, irc, msg, args):
|
||||||
@ -186,7 +186,7 @@ class Fun(callbacks.Privmsg):
|
|||||||
available in the documentation of the Python codecs module:
|
available in the documentation of the Python codecs module:
|
||||||
<http://www.python.org/doc/lib/node126.html>.
|
<http://www.python.org/doc/lib/node126.html>.
|
||||||
"""
|
"""
|
||||||
encoding, text = privmsgs.getArgs(args, needed=2)
|
encoding, text = privmsgs.getArgs(args, required=2)
|
||||||
irc.reply(msg, text.encode(encoding))
|
irc.reply(msg, text.encode(encoding))
|
||||||
|
|
||||||
def decode(self, irc, msg, args):
|
def decode(self, irc, msg, args):
|
||||||
@ -196,7 +196,7 @@ class Fun(callbacks.Privmsg):
|
|||||||
available in the documentation of the Python codecs module:
|
available in the documentation of the Python codecs module:
|
||||||
<http://www.python.org/doc/lib/node126.html>.
|
<http://www.python.org/doc/lib/node126.html>.
|
||||||
"""
|
"""
|
||||||
encoding, text = privmsgs.getArgs(args, needed=2)
|
encoding, text = privmsgs.getArgs(args, required=2)
|
||||||
irc.reply(msg, text.decode(encoding).encode('utf-8'))
|
irc.reply(msg, text.decode(encoding).encode('utf-8'))
|
||||||
|
|
||||||
def hexlify(self, irc, msg, args):
|
def hexlify(self, irc, msg, args):
|
||||||
@ -410,7 +410,7 @@ class Fun(callbacks.Privmsg):
|
|||||||
Returns the levenshtein distance (also known as the "edit distance"
|
Returns the levenshtein distance (also known as the "edit distance"
|
||||||
between <string1> and <string2>
|
between <string1> and <string2>
|
||||||
"""
|
"""
|
||||||
(s1, s2) = privmsgs.getArgs(args, needed=2)
|
(s1, s2) = privmsgs.getArgs(args, required=2)
|
||||||
irc.reply(msg, str(utils.distance(s1, s2)))
|
irc.reply(msg, str(utils.distance(s1, s2)))
|
||||||
|
|
||||||
def soundex(self, irc, msg, args):
|
def soundex(self, irc, msg, args):
|
||||||
|
@ -184,7 +184,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
Gives you a standard, random BOFH excuse or the excuse with the given
|
Gives you a standard, random BOFH excuse or the excuse with the given
|
||||||
<id>.
|
<id>.
|
||||||
"""
|
"""
|
||||||
id = privmsgs.getArgs(args, needed=0, optional=1)
|
id = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
if id:
|
if id:
|
||||||
try:
|
try:
|
||||||
@ -218,7 +218,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
when it used that lart against, say, jemfinch, to say '/me slices
|
when it used that lart against, say, jemfinch, to say '/me slices
|
||||||
jemfinch in half with a free AOL cd'
|
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()
|
table = table.lower()
|
||||||
try:
|
try:
|
||||||
name = ircdb.users.getUser(msg.prefix).name
|
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
|
Removes the data, referred to in the first argument, with the id
|
||||||
number <id> from the database.
|
number <id> from the database.
|
||||||
"""
|
"""
|
||||||
(table, id) = privmsgs.getArgs(args, needed=2)
|
(table, id) = privmsgs.getArgs(args, required=2)
|
||||||
table = table.lower()
|
table = table.lower()
|
||||||
try:
|
try:
|
||||||
ircdb.users.getUser(msg.prefix).name
|
ircdb.users.getUser(msg.prefix).name
|
||||||
@ -280,7 +280,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
zero-based index into the db; <regexp> is a regular expression of the
|
zero-based index into the db; <regexp> is a regular expression of the
|
||||||
form s/regexp/replacement/flags.
|
form s/regexp/replacement/flags.
|
||||||
"""
|
"""
|
||||||
(table, id, regexp) = privmsgs.getArgs(args, needed=3)
|
(table, id, regexp) = privmsgs.getArgs(args, required=3)
|
||||||
table = table.lower()
|
table = table.lower()
|
||||||
try:
|
try:
|
||||||
name = ircdb.users.getUser(msg.prefix).name
|
name = ircdb.users.getUser(msg.prefix).name
|
||||||
@ -341,7 +341,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
|
|
||||||
Gets the record with id <id> from the table specified.
|
Gets the record with id <id> from the table specified.
|
||||||
"""
|
"""
|
||||||
(table, id) = privmsgs.getArgs(args, needed=2)
|
(table, id) = privmsgs.getArgs(args, required=2)
|
||||||
table = table.lower()
|
table = table.lower()
|
||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
@ -366,7 +366,7 @@ class FunDB(callbacks.Privmsg):
|
|||||||
|
|
||||||
Gets the info for the record with id <id> from the table specified.
|
Gets the info for the record with id <id> from the table specified.
|
||||||
"""
|
"""
|
||||||
(table, id) = privmsgs.getArgs(args, needed=2)
|
(table, id) = privmsgs.getArgs(args, required=2)
|
||||||
table = table.lower()
|
table = table.lower()
|
||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
|
@ -113,7 +113,7 @@ class Lookup(callbacks.Privmsg):
|
|||||||
for in conf.dataDir. Use 'lookup <name> <key>' to get the value of
|
for in conf.dataDir. Use 'lookup <name> <key>' to get the value of
|
||||||
the key in the file.
|
the key in the file.
|
||||||
"""
|
"""
|
||||||
(name, filename) = privmsgs.getArgs(args, needed=2)
|
(name, filename) = privmsgs.getArgs(args, required=2)
|
||||||
db = getDb()
|
db = getDb()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
try:
|
try:
|
||||||
|
@ -213,7 +213,7 @@ class Math(callbacks.Privmsg):
|
|||||||
n = args.pop(0)
|
n = args.pop(0)
|
||||||
else:
|
else:
|
||||||
n = 1
|
n = 1
|
||||||
(unit1, to, unit2) = privmsgs.getArgs(args, needed=3)
|
(unit1, to, unit2) = privmsgs.getArgs(args, required=3)
|
||||||
if to != 'to':
|
if to != 'to':
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
try:
|
try:
|
||||||
|
@ -368,7 +368,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
Returns the literal factoid for the given factoid key. No parsing of
|
Returns the literal factoid for the given factoid key. No parsing of
|
||||||
the factoid value is done as it is with normal retrieval.
|
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 = self.db.cursor()
|
||||||
cursor.execute("""SELECT fact FROM factoids WHERE key LIKE %s""", key)
|
cursor.execute("""SELECT fact FROM factoids WHERE key LIKE %s""", key)
|
||||||
if cursor.rowcount == 0:
|
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.
|
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
|
# Start building the response string
|
||||||
s = key + ": "
|
s = key + ": "
|
||||||
# Next, get all the info and build the response piece by piece
|
# Next, get all the info and build the response piece by piece
|
||||||
@ -433,7 +433,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(msg, conf.replyNotRegistered)
|
irc.error(msg, conf.replyNotRegistered)
|
||||||
return
|
return
|
||||||
key = privmsgs.getArgs(args, needed=1)
|
key = privmsgs.getArgs(args, required=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT created_by, locked_by FROM factoids
|
cursor.execute("""SELECT created_by, locked_by FROM factoids
|
||||||
WHERE key LIKE %s""", key)
|
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
|
author has an integer name, you'll have to use that author's id to use
|
||||||
this function (so don't use integer usernames!).
|
this function (so don't use integer usernames!).
|
||||||
"""
|
"""
|
||||||
author = privmsgs.getArgs(args, needed=1)
|
author = privmsgs.getArgs(args, required=1)
|
||||||
try:
|
try:
|
||||||
id = ircdb.users.getUserId(author)
|
id = ircdb.users.getUserId(author)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -568,7 +568,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
|
|
||||||
Lists the keys of the factoids whose key contains the provided text.
|
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 + '%'
|
glob = '%' + search + '%'
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT key FROM factoids
|
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.
|
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 + '%'
|
glob = '%' + search + '%'
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT key FROM factoids
|
cursor.execute("""SELECT key FROM factoids
|
||||||
@ -614,7 +614,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(msg, conf.replyNotRegistered)
|
irc.error(msg, conf.replyNotRegistered)
|
||||||
return
|
return
|
||||||
key = privmsgs.getArgs(args, needed=1)
|
key = privmsgs.getArgs(args, required=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT key, locked_at FROM factoids
|
cursor.execute("""SELECT key, locked_at FROM factoids
|
||||||
WHERE key LIKE %s""", key)
|
WHERE key LIKE %s""", key)
|
||||||
|
@ -153,7 +153,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
in the channel itself.
|
in the channel itself.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
channel = privmsgs.getChannel(msg, args)
|
||||||
number = privmsgs.getArgs(args, needed=0, optional=1)
|
number = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
if number:
|
if number:
|
||||||
self._readnews(irc, msg, [channel, number])
|
self._readnews(irc, msg, [channel, number])
|
||||||
return
|
return
|
||||||
@ -195,7 +195,7 @@ class News(plugins.ChannelDBHandler, callbacks.Privmsg):
|
|||||||
s/text/replacement/flags. <channel> is only necessary if the message
|
s/text/replacement/flags. <channel> is only necessary if the message
|
||||||
isn't sent on the channel itself.
|
isn't sent on the channel itself.
|
||||||
"""
|
"""
|
||||||
(id, regexp) = privmsgs.getArgs(args, needed=2)
|
(id, regexp) = privmsgs.getArgs(args, required=2)
|
||||||
try:
|
try:
|
||||||
replacer = utils.perlReToReplacer(regexp)
|
replacer = utils.perlReToReplacer(regexp)
|
||||||
except ValueError, e:
|
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.
|
is only necessary if the message isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
channel = privmsgs.getChannel(msg, args)
|
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)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
if id:
|
if id:
|
||||||
|
@ -114,7 +114,7 @@ class Note(callbacks.Privmsg):
|
|||||||
|
|
||||||
Sends a new note to the user specified.
|
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):
|
if ircdb.users.hasUser(name):
|
||||||
toId = ircdb.users.getUserId(name)
|
toId = ircdb.users.getUserId(name)
|
||||||
else:
|
else:
|
||||||
|
@ -179,7 +179,7 @@ class Poll(callbacks.Privmsg):
|
|||||||
Vote yes or no on an active poll with the given id. This command can
|
Vote yes or no on an active poll with the given id. This command can
|
||||||
also be used to override the previous vote.
|
also be used to override the previous vote.
|
||||||
"""
|
"""
|
||||||
(id, vote) = privmsgs.getArgs(args, needed=2)
|
(id, vote) = privmsgs.getArgs(args, required=2)
|
||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -167,7 +167,7 @@ class Relay(callbacks.Privmsg, plugins.Configurable):
|
|||||||
if not self.started:
|
if not self.started:
|
||||||
irc.error(msg, 'You must use the start command first.')
|
irc.error(msg, 'You must use the start command first.')
|
||||||
return
|
return
|
||||||
abbreviation, server = privmsgs.getArgs(args, needed=2)
|
abbreviation, server = privmsgs.getArgs(args, required=2)
|
||||||
if isinstance(irc, irclib.Irc):
|
if isinstance(irc, irclib.Irc):
|
||||||
realIrc = irc
|
realIrc = irc
|
||||||
else:
|
else:
|
||||||
|
@ -78,7 +78,7 @@ class Services(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
irc.error(msg, conf.replyRequiresPrivacy)
|
irc.error(msg, conf.replyRequiresPrivacy)
|
||||||
return
|
return
|
||||||
(self.nick, self.password, nickserv, chanserv) = \
|
(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.nick = ircutils.IrcString(self.nick)
|
||||||
self.nickserv = ircutils.IrcString(nickserv or 'NickServ')
|
self.nickserv = ircutils.IrcString(nickserv or 'NickServ')
|
||||||
self.chanserv = ircutils.IrcString(chanserv or 'ChanServ')
|
self.chanserv = ircutils.IrcString(chanserv or 'ChanServ')
|
||||||
|
@ -177,7 +177,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
|
|||||||
Returns a list of the most recent bugs filed against <project>.
|
Returns a list of the most recent bugs filed against <project>.
|
||||||
Defaults to searching for bugs in the project set by defaultproject.
|
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:
|
if not project:
|
||||||
project = self.configurables.get('default-project', msg.args[0])
|
project = self.configurables.get('default-project', msg.args[0])
|
||||||
if not project:
|
if not project:
|
||||||
@ -221,7 +221,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
|
|||||||
Returns a list of the most recent RFEs filed against <project>.
|
Returns a list of the most recent RFEs filed against <project>.
|
||||||
Defaults to searching for RFEs in the project set by defaultproject.
|
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:
|
if not project:
|
||||||
project = self.configurables.get('default-project', msg.args[0])
|
project = self.configurables.get('default-project', msg.args[0])
|
||||||
if not project:
|
if not project:
|
||||||
|
@ -95,7 +95,7 @@ class Todo(callbacks.Privmsg):
|
|||||||
will return a list of task ids that that user has added to their todo
|
will return a list of task ids that that user has added to their todo
|
||||||
list.
|
list.
|
||||||
"""
|
"""
|
||||||
arg = privmsgs.getArgs(args, needed=0, optional=1)
|
arg = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
|
|
||||||
userid = None
|
userid = None
|
||||||
taskid = None
|
taskid = None
|
||||||
@ -186,7 +186,7 @@ class Todo(callbacks.Privmsg):
|
|||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
irc.error(msg, '%r is an invalid priority' % arg)
|
irc.error(msg, '%r is an invalid priority' % arg)
|
||||||
return
|
return
|
||||||
text = privmsgs.getArgs(rest, needed=1)
|
text = privmsgs.getArgs(rest, required=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""INSERT INTO todo
|
cursor.execute("""INSERT INTO todo
|
||||||
VALUES (NULL, %s, %s, %s, %s, 1)""",
|
VALUES (NULL, %s, %s, %s, %s, 1)""",
|
||||||
@ -205,7 +205,7 @@ class Todo(callbacks.Privmsg):
|
|||||||
irc.error(msg, conf.replyNotRegistered)
|
irc.error(msg, conf.replyNotRegistered)
|
||||||
return
|
return
|
||||||
|
|
||||||
taskid = privmsgs.getArgs(args, needed=1)
|
taskid = privmsgs.getArgs(args, required=1)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT * FROM todo
|
cursor.execute("""SELECT * FROM todo
|
||||||
WHERE id = %s AND userid = %s
|
WHERE id = %s AND userid = %s
|
||||||
@ -277,7 +277,7 @@ class Todo(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(msg, conf.replyNotRegistered)
|
irc.error(msg, conf.replyNotRegistered)
|
||||||
return
|
return
|
||||||
(id, priority) = privmsgs.getArgs(args, needed=2)
|
(id, priority) = privmsgs.getArgs(args, required=2)
|
||||||
cursor = self.db.cursor()
|
cursor = self.db.cursor()
|
||||||
cursor.execute("""SELECT userid, priority FROM todo
|
cursor.execute("""SELECT userid, priority FROM todo
|
||||||
WHERE id = %s AND active = 1""", id)
|
WHERE id = %s AND active = 1""", id)
|
||||||
@ -304,7 +304,7 @@ class Todo(callbacks.Privmsg):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
irc.error(msg, conf.replyNotRegistered)
|
irc.error(msg, conf.replyNotRegistered)
|
||||||
return
|
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
|
# Check the regexp first, it's easier and doesn't require a db query
|
||||||
try:
|
try:
|
||||||
replacer = utils.perlReToReplacer(regexp)
|
replacer = utils.perlReToReplacer(regexp)
|
||||||
|
@ -138,7 +138,7 @@ class Topic(callbacks.Privmsg):
|
|||||||
s/regexp/replacement/flags. <channel> is only necessary if the message
|
s/regexp/replacement/flags. <channel> is only necessary if the message
|
||||||
isn't sent in the channel itself.
|
isn't sent in the channel itself.
|
||||||
"""
|
"""
|
||||||
(number, regexp) = privmsgs.getArgs(args, needed=2)
|
(number, regexp) = privmsgs.getArgs(args, required=2)
|
||||||
try:
|
try:
|
||||||
number = int(number)
|
number = int(number)
|
||||||
if number > 0:
|
if number > 0:
|
||||||
|
@ -71,7 +71,7 @@ class Utilities(callbacks.Privmsg):
|
|||||||
<text>. The first and second arguments must necessarily be the same
|
<text>. The first and second arguments must necessarily be the same
|
||||||
length.
|
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)))
|
irc.reply(msg, text.translate(string.maketrans(bad, good)))
|
||||||
|
|
||||||
def strupper(self, irc, msg, args):
|
def strupper(self, irc, msg, args):
|
||||||
@ -114,7 +114,7 @@ class Utilities(callbacks.Privmsg):
|
|||||||
thing as strjoin "", since if <string 2> contains spaces, they won't be
|
thing as strjoin "", since if <string 2> contains spaces, they won't be
|
||||||
removed by strconcat.
|
removed by strconcat.
|
||||||
"""
|
"""
|
||||||
(first, second) = privmsgs.getArgs(args, needed=2)
|
(first, second) = privmsgs.getArgs(args, required=2)
|
||||||
irc.reply(msg, first+second)
|
irc.reply(msg, first+second)
|
||||||
|
|
||||||
def echo(self, irc, msg, args):
|
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
|
s/regexp/replacement/flags, returns the result of applying such a
|
||||||
regexp to <text>
|
regexp to <text>
|
||||||
"""
|
"""
|
||||||
(regexp, text) = privmsgs.getArgs(args, needed=2)
|
(regexp, text) = privmsgs.getArgs(args, required=2)
|
||||||
f = None
|
f = None
|
||||||
try:
|
try:
|
||||||
r = utils.perlReToPythonRe(regexp)
|
r = utils.perlReToPythonRe(regexp)
|
||||||
|
@ -94,7 +94,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
this will cause the bot to "cycle", or PART and then JOIN the channel.
|
this will cause the bot to "cycle", or PART and then JOIN the channel.
|
||||||
If <key> is given, join the channel using that key.
|
If <key> 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:
|
if not key:
|
||||||
key = None
|
key = None
|
||||||
irc.queueMsg(ircmsgs.part(channel))
|
irc.queueMsg(ircmsgs.part(channel))
|
||||||
@ -249,7 +249,7 @@ class Channel(callbacks.Privmsg):
|
|||||||
The <channel> argument is only necessary if the message isn't being
|
The <channel> argument is only necessary if the message isn't being
|
||||||
sent in the channel itself.
|
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
|
channel = channelarg or channel
|
||||||
c = ircdb.channels.getChannel(channel)
|
c = ircdb.channels.getChannel(channel)
|
||||||
if len(c.ignores) == 0:
|
if len(c.ignores) == 0:
|
||||||
|
10
src/Misc.py
10
src/Misc.py
@ -72,7 +72,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
for (option, argument) in optlist:
|
for (option, argument) in optlist:
|
||||||
if option == '--private':
|
if option == '--private':
|
||||||
evenPrivate = True
|
evenPrivate = True
|
||||||
name = privmsgs.getArgs(rest, needed=0, optional=1)
|
name = privmsgs.getArgs(rest, required=0, optional=1)
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
if not name:
|
if not name:
|
||||||
names = [cb.name() for cb in irc.callbacks
|
names = [cb.name() for cb in irc.callbacks
|
||||||
@ -172,7 +172,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
Returns the hostmask of <nick>. If <nick> isn't given, return the
|
Returns the hostmask of <nick>. If <nick> isn't given, return the
|
||||||
hostmask of the person giving the command.
|
hostmask of the person giving the command.
|
||||||
"""
|
"""
|
||||||
nick = privmsgs.getArgs(args, needed=0, optional=1)
|
nick = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
try:
|
try:
|
||||||
if nick:
|
if nick:
|
||||||
irc.reply(msg, irc.state.nickToHostmask(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
|
Returns the size of the various logfiles in use. If given a specific
|
||||||
logfile, returns only the size of that logfile.
|
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 filename:
|
||||||
if not filename.endswith('.log'):
|
if not filename.endswith('.log'):
|
||||||
irc.error(msg, 'That filename doesn\'t appear to be a log.')
|
irc.error(msg, 'That filename doesn\'t appear to be a log.')
|
||||||
@ -243,7 +243,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
If <nick> is given, it takes the continuation of the last command from
|
If <nick> is given, it takes the continuation of the last command from
|
||||||
<nick> instead of the person sending this message.
|
<nick> 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]
|
userHostmask = msg.prefix.split('!', 1)[1]
|
||||||
if nick:
|
if nick:
|
||||||
try:
|
try:
|
||||||
@ -330,7 +330,7 @@ class Misc(callbacks.Privmsg):
|
|||||||
Tells the <nick|channel> whatever <text> is. Use nested commands to
|
Tells the <nick|channel> whatever <text> is. Use nested commands to
|
||||||
your benefit here.
|
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)
|
s = '%s wants me to tell you: %s' % (msg.nick, text)
|
||||||
irc.queueMsg(ircmsgs.privmsg(target, s))
|
irc.queueMsg(ircmsgs.privmsg(target, s))
|
||||||
raise callbacks.CannotNest
|
raise callbacks.CannotNest
|
||||||
|
@ -202,7 +202,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
variable type with only the <name> argument and sets the value of the
|
variable type with only the <name> argument and sets the value of the
|
||||||
variable to <value> when both arguments are given.
|
variable to <value> 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 name and value:
|
||||||
if conf.allowEval:
|
if conf.allowEval:
|
||||||
try:
|
try:
|
||||||
|
@ -60,7 +60,7 @@ class User(callbacks.Privmsg):
|
|||||||
on disk, rather than being stored in plaintext.
|
on disk, rather than being stored in plaintext.
|
||||||
"""
|
"""
|
||||||
(optlist, rest) = getopt.getopt(args, '', ['hashed'])
|
(optlist, rest) = getopt.getopt(args, '', ['hashed'])
|
||||||
(name, password) = privmsgs.getArgs(rest, needed=2)
|
(name, password) = privmsgs.getArgs(rest, required=2)
|
||||||
hashed = False
|
hashed = False
|
||||||
for (option, arg) in optlist:
|
for (option, arg) in optlist:
|
||||||
if option == '--hashed':
|
if option == '--hashed':
|
||||||
@ -94,7 +94,7 @@ class User(callbacks.Privmsg):
|
|||||||
|
|
||||||
Unregisters <name> from the user database.
|
Unregisters <name> 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):
|
if not self._checkNotChannel(irc, msg, password):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
@ -117,7 +117,7 @@ class User(callbacks.Privmsg):
|
|||||||
If you include the <password> parameter, this message must be sent
|
If you include the <password> parameter, this message must be sent
|
||||||
to the bot privately (not on a channel).
|
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):
|
if not self._checkNotChannel(irc, msg, password):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
@ -312,7 +312,7 @@ class Configurable(object):
|
|||||||
if not ircdb.checkCapability(msg.prefix, capability):
|
if not ircdb.checkCapability(msg.prefix, capability):
|
||||||
irc.error(msg, conf.replyNoCapability % capability)
|
irc.error(msg, conf.replyNoCapability % capability)
|
||||||
return
|
return
|
||||||
(name, value) = privmsgs.getArgs(args, needed=0, optional=2)
|
(name, value) = privmsgs.getArgs(args, required=0, optional=2)
|
||||||
if not name:
|
if not name:
|
||||||
irc.reply(msg, utils.commaAndify(self.configurables.names()))
|
irc.reply(msg, utils.commaAndify(self.configurables.names()))
|
||||||
return
|
return
|
||||||
|
@ -58,22 +58,22 @@ def getChannel(msg, args):
|
|||||||
raise callbacks.Error, 'Command must be sent in a channel or ' \
|
raise callbacks.Error, 'Command must be sent in a channel or ' \
|
||||||
'include a channel in its arguments.'
|
'include a channel in its arguments.'
|
||||||
|
|
||||||
def getArgs(args, needed=1, optional=0):
|
def getArgs(args, required=1, optional=0):
|
||||||
"""Take the needed arguments from args.
|
"""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.
|
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.
|
let the caller handle sending the help message.
|
||||||
"""
|
"""
|
||||||
if len(args) < needed:
|
if len(args) < required:
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
if len(args) < needed + optional:
|
if len(args) < required + optional:
|
||||||
ret = list(args) + ([''] * (needed + optional - len(args)))
|
ret = list(args) + ([''] * (required + optional - len(args)))
|
||||||
elif len(args) >= needed + optional:
|
elif len(args) >= required + optional:
|
||||||
ret = list(args[:needed + optional - 1])
|
ret = list(args[:required + optional - 1])
|
||||||
ret.append(' '.join(args[needed + optional - 1:]))
|
ret.append(' '.join(args[required + optional - 1:]))
|
||||||
if len(ret) == 1:
|
if len(ret) == 1:
|
||||||
return ret[0]
|
return ret[0]
|
||||||
else:
|
else:
|
||||||
|
@ -52,14 +52,14 @@ class FunctionsTest(unittest.TestCase):
|
|||||||
def testGetArgs(self):
|
def testGetArgs(self):
|
||||||
args = ['foo', 'bar', 'baz']
|
args = ['foo', 'bar', 'baz']
|
||||||
self.assertEqual(privmsgs.getArgs(args), ' '.join(args))
|
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:])])
|
[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,
|
self.assertRaises(callbacks.ArgumentError,
|
||||||
privmsgs.getArgs, args, needed=4)
|
privmsgs.getArgs, args, required=4)
|
||||||
self.assertEqual(privmsgs.getArgs(args, needed=3, optional=1),
|
self.assertEqual(privmsgs.getArgs(args, required=3, optional=1),
|
||||||
args + [''])
|
args + [''])
|
||||||
self.assertEqual(privmsgs.getArgs(args, needed=0, optional=1),
|
self.assertEqual(privmsgs.getArgs(args, required=0, optional=1),
|
||||||
' '.join(args))
|
' '.join(args))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user