mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Channel: nicks: add --count argument, which outputs only the count of nicks in channel.
also add tests for the nick command.
This commit is contained in:
parent
80491fddb1
commit
a91bc318dc
@ -777,11 +777,12 @@ class Channel(callbacks.Plugin):
|
||||
optional(('plugin', False)),
|
||||
additional('commandName')])
|
||||
|
||||
def nicks(self, irc, msg, args, channel):
|
||||
"""[<channel>]
|
||||
def nicks(self, irc, msg, args, channel, optlist):
|
||||
"""[<channel>] [--count]
|
||||
|
||||
Returns the nicks in <channel>. <channel> is only necessary if the
|
||||
message isn't sent in the channel itself.
|
||||
message isn't sent in the channel itself. Returns only the number of
|
||||
nicks if --count option is provided.
|
||||
"""
|
||||
# Make sure we don't elicit information about private channels to
|
||||
# people or channels that shouldn't know
|
||||
@ -791,9 +792,14 @@ class Channel(callbacks.Plugin):
|
||||
msg.nick not in irc.state.channels[channel].users):
|
||||
irc.error('You don\'t have access to that information.')
|
||||
L = list(irc.state.channels[channel].users)
|
||||
utils.sortBy(str.lower, L)
|
||||
irc.reply(utils.str.commaAndify(L))
|
||||
nicks = wrap(nicks, ['inChannel'])
|
||||
keys = [option for (option, arg) in optlist]
|
||||
if 'count' not in keys:
|
||||
utils.sortBy(str.lower, L)
|
||||
irc.reply(utils.str.commaAndify(L))
|
||||
else:
|
||||
irc.reply(str(len(L)))
|
||||
nicks = wrap(nicks, ['inChannel',
|
||||
getopts({'count':''})])
|
||||
|
||||
def alertOps(self, irc, channel, s, frm=None):
|
||||
"""Internal message for notifying all the #channel,ops in a channel of
|
||||
|
@ -214,5 +214,9 @@ class ChannelTestCase(ChannelPluginTestCase):
|
||||
finally:
|
||||
conf.supybot.protocols.irc.banmask.setValue(orig)
|
||||
|
||||
def testNicks(self):
|
||||
self.assertResponse('channel nicks', 'bar, foo, and test')
|
||||
self.assertResponse('channel nicks --count', '3')
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user