def test_slash_command_matches_without_bot_mention(): command = "/command" slash_command = SlashCommandActivity(command, False, AsyncMock()) context = create_command_context(create_message_sent(f"<div><p>{command}</p></div>")) assert slash_command.matches(context) context = create_command_context(create_message_sent(f"<div><p><span>@{BOT_NAME}</span> {command}</p></div>")) assert not slash_command.matches(context) context = create_command_context(create_message_sent(f"<div><p>/other_command</p></div>")) assert not slash_command.matches(context)
async def test_slash_command_on_activity_calls_callback(message_sent): listener_callback = AsyncMock() slash_command = SlashCommandActivity("/command", False, listener_callback) context = create_command_context(message_sent) await slash_command.on_activity(context) listener_callback.assert_called_once_with(context)
def decorator(func): logger.debug( "Registering slash command with command=%s, mention_bot=%s", command, mention_bot) self.register(SlashCommandActivity(command, mention_bot, func)) return func