Class SlashCommand
java.lang.Object
com.symphony.bdk.core.activity.AbstractActivity<V4MessageSent,C>
com.symphony.bdk.core.activity.command.CommandActivity<CommandContext>
com.symphony.bdk.core.activity.command.SlashCommand
- Direct Known Subclasses:
HelpCommand
A "slash" command if the most basic action that can be performed by an end-user through the chat.
-
Constructor Summary
ModifierConstructorDescriptionprotected
SlashCommand
(String slashCommandPattern, boolean requiresBotMention, boolean isAsync, Consumer<CommandContext> callback, String description) Default protected constructor, new instances from static methods only. -
Method Summary
Modifier and TypeMethodDescriptionprotected CommandContext
createContextInstance
(V4Initiator initiator, V4MessageSent event) boolean
int
hashCode()
protected ActivityInfo
info()
Build activity info.boolean
matcher()
Any kind of activity must provide anActivityMatcher
in order to detect if it can be applied to a certain user input.void
onActivity
(CommandContext context) Contain the activity business logic.static SlashCommand
slash
(String slashCommandPattern, boolean requiresBotMention, boolean isAsync, Consumer<CommandContext> callback, String description) Returns a newSlashCommand
instance.static SlashCommand
slash
(String slashCommandPattern, boolean requiresBotMention, Consumer<CommandContext> callback) Returns a newSlashCommand
instance.static SlashCommand
slash
(String slashCommandPattern, boolean requiresBotMention, Consumer<CommandContext> callback, String description) Returns a newSlashCommand
instance.static SlashCommand
slash
(String slashCommandPattern, Consumer<CommandContext> callback) Returns a newSlashCommand
instance.static SlashCommand
slash
(String slashCommandPattern, Consumer<CommandContext> callback, String description) Returns a newSlashCommand
instance.Methods inherited from class com.symphony.bdk.core.activity.command.CommandActivity
beforeMatcher, bindToRealTimeEventsSource
Methods inherited from class com.symphony.bdk.core.activity.AbstractActivity
getInfo, processEvent
-
Constructor Details
-
SlashCommand
protected SlashCommand(@Nonnull String slashCommandPattern, boolean requiresBotMention, boolean isAsync, @Nonnull Consumer<CommandContext> callback, String description) Default protected constructor, new instances from static methods only.
-
-
Method Details
-
slash
public static SlashCommand slash(@Nonnull String slashCommandPattern, @Nonnull Consumer<CommandContext> callback) Returns a newSlashCommand
instance.- Parameters:
slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').callback
- Callback to be processed when command is detected.
-
slash
public static SlashCommand slash(@Nonnull String slashCommandPattern, boolean requiresBotMention, @Nonnull Consumer<CommandContext> callback) Returns a newSlashCommand
instance.- Parameters:
slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').requiresBotMention
- Indicates whether the bot has to be mentioned in order to trigger the command.callback
- Callback to be processed when command is detected.- Throws:
IllegalArgumentException
- if command name if empty.
-
slash
public static SlashCommand slash(@Nonnull String slashCommandPattern, @Nonnull Consumer<CommandContext> callback, String description) Returns a newSlashCommand
instance.- Parameters:
slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').callback
- Callback to be processed when command is detected.description
- The summary of the command.- Returns:
- a
SlashCommand
instance.
-
slash
public static SlashCommand slash(@Nonnull String slashCommandPattern, boolean requiresBotMention, @Nonnull Consumer<CommandContext> callback, String description) Returns a newSlashCommand
instance.- Parameters:
slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').requiresBotMention
- Indicates whether the bot has to be mentioned in order to trigger the command.callback
- Callback to be processed when command is detected.description
- The summary of the command.- Returns:
- a
SlashCommand
instance.
-
slash
public static SlashCommand slash(@Nonnull String slashCommandPattern, boolean requiresBotMention, boolean isAsync, @Nonnull Consumer<CommandContext> callback, String description) Returns a newSlashCommand
instance.- Parameters:
slashCommandPattern
- Pattern of the command (ex: '/gif' or 'gif {option} {@mention}').requiresBotMention
- Indicates whether the bot has to be mentioned in order to trigger the command.isAsync
- Indicated whether the command is asynchronous or not.callback
- Callback to be processed when command is detected.description
- The summary of the command.- Returns:
- a
SlashCommand
instance.
-
matcher
Description copied from class:AbstractActivity
Any kind of activity must provide anActivityMatcher
in order to detect if it can be applied to a certain user input.- Specified by:
matcher
in classAbstractActivity<V4MessageSent,
CommandContext> - Returns:
- an
ActivityMatcher
implementation.
-
onActivity
Description copied from class:AbstractActivity
Contain the activity business logic. Executed only if theActivityMatcher.matches(ActivityContext)
returned a true value.- Specified by:
onActivity
in classAbstractActivity<V4MessageSent,
CommandContext> - Parameters:
context
- The activity context object.
-
isAsynchronous
public boolean isAsynchronous()- Overrides:
isAsynchronous
in classAbstractActivity<V4MessageSent,
CommandContext>
-
info
Description copied from class:AbstractActivity
Build activity info.- Specified by:
info
in classAbstractActivity<V4MessageSent,
CommandContext>
-
createContextInstance
- Overrides:
createContextInstance
in classAbstractActivity<V4MessageSent,
CommandContext>
-
equals
-
hashCode
public int hashCode()
-