mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-25 19:44:13 +01:00
Moved the list of commands from cmdstats to the commands command.
This commit is contained in:
parent
46ebfce1cd
commit
9f24c13be8
@ -110,24 +110,38 @@ class Status(callbacks.Privmsg):
|
|||||||
|
|
||||||
Returns some interesting command-related statistics.
|
Returns some interesting command-related statistics.
|
||||||
"""
|
"""
|
||||||
commands = sets.Set()
|
commands = 0
|
||||||
callbacksPrivmsgs = 0
|
callbacksPrivmsg = 0
|
||||||
for cb in irc.callbacks:
|
for cb in irc.callbacks:
|
||||||
if isinstance(cb, callbacks.Privmsg) and cb.public:
|
if isinstance(cb, callbacks.Privmsg) and cb.public:
|
||||||
callbacksPrivmsgs += 1
|
if not isinstance(cb, callbacks.PrivmsgRegexp):
|
||||||
|
callbacksPrivmsg += 1
|
||||||
|
for attr in dir(cb):
|
||||||
|
if cb.isCommand(attr) and \
|
||||||
|
attr == callbacks.canonicalName(attr):
|
||||||
|
commands += 1
|
||||||
|
s = 'I offer a total of %s in %s. I have processed %s.' % \
|
||||||
|
(utils.nItems(commands, 'command'),
|
||||||
|
utils.nItems(callbacksPrivmsg, 'plugin', 'command-based'),
|
||||||
|
world.commandsProcessed)
|
||||||
|
irc.reply(msg, s)
|
||||||
|
|
||||||
|
def commands(self, irc, msg, args):
|
||||||
|
"""takes no arguments
|
||||||
|
|
||||||
|
Returns a list of the commands offered by the bot.
|
||||||
|
"""
|
||||||
|
commands = sets.Set()
|
||||||
|
for cb in irc.callbacks:
|
||||||
|
if isinstance(cb, callbacks.Privmsg) and \
|
||||||
|
not isinstance(cb, callbacks.PrivmsgRegexp) and cb.public:
|
||||||
for attr in dir(cb):
|
for attr in dir(cb):
|
||||||
if cb.isCommand(attr) and \
|
if cb.isCommand(attr) and \
|
||||||
attr == callbacks.canonicalName(attr):
|
attr == callbacks.canonicalName(attr):
|
||||||
commands.add(attr)
|
commands.add(attr)
|
||||||
commands = list(commands)
|
commands = list(commands)
|
||||||
commands.sort()
|
commands.sort()
|
||||||
s = 'I offer a total of %s in %s. ' \
|
irc.reply(msg, utils.commaAndify(commands))
|
||||||
'I have processed %s. My public commands include %s.' % \
|
|
||||||
(utils.nItems(len(commands), 'command'),
|
|
||||||
utils.nItems(callbacksPrivmsgs, 'plugin', 'command-based'),
|
|
||||||
utils.nItems(world.commandsProcessed, 'command', 'individual'),
|
|
||||||
utils.commaAndify(commands))
|
|
||||||
irc.reply(msg, s)
|
|
||||||
|
|
||||||
def uptime(self, irc, msg, args):
|
def uptime(self, irc, msg, args):
|
||||||
"""takes no arguments.
|
"""takes no arguments.
|
||||||
|
@ -45,6 +45,9 @@ class StatusTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
def testCmdstats(self):
|
def testCmdstats(self):
|
||||||
self.assertNotError('cmdstats')
|
self.assertNotError('cmdstats')
|
||||||
|
|
||||||
|
def testCommands(self):
|
||||||
|
self.assertNotError('commands')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user