CtcpNext: update docs, add "show" command

Closes #37.
This commit is contained in:
James Lu 2015-10-02 20:26:19 -07:00
parent f5325dfa43
commit b42592a7ee

View File

@ -110,9 +110,9 @@ class CtcpNext(callbacks.PluginRegexp):
payload, msg.prefix) payload, msg.prefix)
def set(self, irc, msg, args, ctcp, response): def set(self, irc, msg, args, ctcp, response):
"""<ctcp> <response> """<ctcp type> <response>
Sets the response for <ctcp> to <response>. Exceptions include Sets the response for <ctcp type> to <response>. Exceptions include
ACTION and PING, which are handled accordingly. All the standard ACTION and PING, which are handled accordingly. All the standard
substitutes ($version, $now, $nick, etc.) are handled properly. substitutes ($version, $now, $nick, etc.) are handled properly.
""" """
@ -125,19 +125,31 @@ class CtcpNext(callbacks.PluginRegexp):
set = wrap(set, ['admin', 'somethingWithoutSpaces', 'text']) set = wrap(set, ['admin', 'somethingWithoutSpaces', 'text'])
def unset(self, irc, msg, args, ctcp): def unset(self, irc, msg, args, ctcp):
"""<ctcp> """<ctcp type>
Unsets the response for <ctcp>. Unsets the response for <ctcp type>.
""" """
ctcp = ctcp.upper() ctcp = ctcp.upper()
try: try:
del self.db[ctcp] del self.db[ctcp]
except KeyError: except KeyError:
irc.error("No such CTCP '%s' exists." % ctcp, Raise=True) irc.error("No response is set for CTCP '%s'." % ctcp, Raise=True)
else: else:
irc.replySuccess() irc.replySuccess()
unset = wrap(unset, ['admin', 'somethingWithoutSpaces']) unset = wrap(unset, ['admin', 'somethingWithoutSpaces'])
def show(self, irc, msg, args, ctcp):
"""<ctcp type>
Shows the configured response for <ctcp type>, if it exists.
"""
ctcp = ctcp.upper()
try:
irc.reply(self.db[ctcp])
except KeyError:
irc.error("No response is set for CTCP '%s'." % ctcp, Raise=True)
show = wrap(show, ['somethingWithoutSpaces'])
def list(self, irc, msg, args): def list(self, irc, msg, args):
"""takes no arguments. """takes no arguments.