mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Made indexing start from 1 instead of 0.
This commit is contained in:
parent
747b20d04e
commit
a8d7de246d
@ -116,17 +116,19 @@ class Topic(callbacks.Privmsg):
|
||||
index into the topics. <channel> is only necessary if the message
|
||||
isn't sent in the channel itself.
|
||||
"""
|
||||
i = privmsgs.getArgs(args)
|
||||
number = privmsgs.getArgs(args)
|
||||
try:
|
||||
i = int(i)
|
||||
number = int(number)
|
||||
if number >= 0:
|
||||
number -= 1
|
||||
except ValueError:
|
||||
irc.error(msg, 'The argument must be a valid integer.')
|
||||
return
|
||||
topics = irc.state.getTopic(channel).split(self.topicSeparator)
|
||||
try:
|
||||
irc.reply(msg, topics[i])
|
||||
irc.reply(msg, topics[number])
|
||||
except IndexError:
|
||||
irc.error(msg, 'That\'s not a valid index.')
|
||||
irc.error(msg, 'That\'s not a valid topic.')
|
||||
return
|
||||
gettopic = privmsgs.channel(gettopic)
|
||||
|
||||
@ -142,6 +144,8 @@ class Topic(callbacks.Privmsg):
|
||||
(number, regexp) = privmsgs.getArgs(args, needed=2)
|
||||
try:
|
||||
number = int(number)
|
||||
if number >= 0:
|
||||
number -= 1
|
||||
except ValueError:
|
||||
irc.error(msg, 'The <number> argument must be a number.')
|
||||
return
|
||||
@ -187,6 +191,8 @@ class Topic(callbacks.Privmsg):
|
||||
"""
|
||||
try:
|
||||
number = int(privmsgs.getArgs(args))
|
||||
if number >= 0:
|
||||
number -= 1
|
||||
except ValueError:
|
||||
irc.error(msg, 'The argument must be a number.')
|
||||
return
|
||||
|
@ -52,9 +52,9 @@ class TopicTestCase(PluginTestCase, PluginDocumentation):
|
||||
_ = self.getMsg('addtopic #foo baz')
|
||||
self.assertRegexp('changetopic #foo -1 s/baz/biff/',
|
||||
r'foo.*bar.*biff')
|
||||
self.assertRegexp('changetopic #foo 1 s/bar/baz/',
|
||||
self.assertRegexp('changetopic #foo 2 s/bar/baz/',
|
||||
r'foo.*baz.*biff')
|
||||
self.assertRegexp('changetopic #foo 0 s/foo/bar/',
|
||||
self.assertRegexp('changetopic #foo 1 s/foo/bar/',
|
||||
r'bar.*baz.*biff')
|
||||
self.assertRegexp('changetopic #foo -2 s/baz/bazz/',
|
||||
r'bar.*bazz.*biff')
|
||||
|
Loading…
Reference in New Issue
Block a user