plugin XEP-0199: implementation of XMPP Ping

This commit is contained in:
Goffi 2018-11-10 10:16:38 +01:00
commit 3a07122da9

View file

@ -57,7 +57,8 @@ class TextCommands(object):
# should be downloadable independently)
HELP_SUGGESTION = _(
"Type '/help' to get a list of the available commands. If you didn't want to use a command, please start your message with '//' to escape the slash."
u"Type '/help' to get a list of the available commands. If you didn't want to "
u"use a command, please start your message with '//' to escape the slash."
)
def __init__(self, host):
@ -75,7 +76,8 @@ class TextCommands(object):
@param cmd: function or method callback for the command,
its docstring will be used for self documentation in the following way:
- first line is the command short documentation, shown with /help
- @command keyword can be used, see http://wiki.goffi.org/wiki/Coding_style/en for documentation
- @command keyword can be used,
see http://wiki.goffi.org/wiki/Coding_style/en for documentation
@return (dict): dictionary with parsed data where key can be:
- "doc_short_help" (default: ""): the untranslated short documentation
- "type" (default "all"): the command type as specified in documentation
@ -177,10 +179,12 @@ class TextCommands(object):
"""Add a callback which give information to the /whois command
@param callback: a callback which will be called with the following arguments
- whois_msg: list of information strings to display, callback need to append its own strings to it
- whois_msg: list of information strings to display, callback need to append
its own strings to it
- target_jid: full jid from whom we want information
- profile: %(doc_profile)s
@param priority: priority of the information to show (the highest priority will be displayed first)
@param priority: priority of the information to show (the highest priority will
be displayed first)
"""
self._whois.append((priority, callback))
self._whois.sort(key=lambda item: item[0], reverse=True)
@ -195,11 +199,14 @@ class TextCommands(object):
def _sendMessageCmdHook(self, mess_data, client):
""" Check text commands in message, and react consequently
msg starting with / are potential command. If a command is found, it is executed, else and help message is sent
msg starting with / are potential command. If a command is found, it is executed,
else an help message is sent.
msg starting with // are escaped: they are sent with a single /
commands can abord message sending (if they return anything evaluating to False), or continue it (if they return True), eventually after modifying the message
an "unparsed" key is added to message, containing part of the message not yet parsed
commands can be deferred or not
commands can abord message sending (if they return anything evaluating to False),
or continue it (if they return True), eventually after modifying the message
an "unparsed" key is added to message, containing part of the message not yet
parsed.
Commands can be deferred or not
@param mess_data(dict): data comming from sendMessage trigger
@param profile: %(doc_profile)s
"""