slidge.core.command.chat_command#

Handle slidge commands by exchanging chat messages with the gateway components.

Ad-hoc methods should provide a better UX, but some clients do not support them, so this is mostly a fallback.

Module Contents#

Classes#

Functions#

Attributes#

log

class slidge.core.command.chat_command.ChatCommandProvider(xmpp)[source]#
Parameters:

xmpp (slidge.core.gateway.BaseGateway) –

UNKNOWN = "Wut? I don't know that command: {}"[source]#
register(command)[source]#

Register a command to be used via chat messages with the gateway

Plugins should not call this, any class subclassing Command should be automatically added by slidge core.

Parameters:

command (slidge.core.command.Command) – the new command

async input(jid, text=None, mtype='chat', timeout=60, **msg_kwargs)[source]#

Request arbitrary user input using a simple chat message, and await the result.

You shouldn’t need to call directly bust instead use BaseSession.input() to directly target a user.

NB: When using this, the next message that the user sent to the component will not be transmitted to BaseGateway.on_gateway_message(), but rather intercepted. Await the coroutine to get its content.

Parameters:
  • jid (slixmpp.JID) – The JID we want input from

  • text – A prompt to display for the user

  • mtype (slixmpp.types.MessageTypes) – Message type

  • timeout

Returns:

The user’s reply

Return type:

str

async _handle_message(msg)[source]#
Parameters:

msg (slixmpp.Message) –

async _handle_result(result, msg, session)[source]#
Parameters:
  • result (slidge.core.command.CommandResponseType) –

  • msg (slixmpp.Message) –

async static __wrap_handler(msg, f, *a, **k)[source]#
Parameters:

f (Union[Callable, functools.partial]) –

_handle_help(msg, *rest)[source]#
Parameters:

msg (slixmpp.Message) –

_help(mfrom)[source]#
Parameters:

mfrom (slixmpp.JID) –

_not_found(msg, word)[source]#
Parameters:
  • msg (slixmpp.Message) –

  • word (str) –

slidge.core.command.chat_command.percent_encode(jid)[source]#
Parameters:

jid (slixmpp.JID) –

slidge.core.command.chat_command.log[source]#