struct Slack::Command

Overview

Models events sent by Slack slash commands. Slack allow for slash commands to optionally encode or declode usernames, channel names, and other data.

To learn more, see the Slack API documentation: Slack Commands API

Included Modules

Defined in:

slack/commands/command.cr

Constant Summary

ASSIGNED_TYPES = [api_app_id : String, channel_id : String, channel_name : String, command : String, enterprise_id : String | ::Nil, enterprise_name : String | ::Nil, response_url : String, team_id : String, team_name : String | ::Nil, text : String, trigger_id : String, user_id : String, user_name : String] of TypeDeclaration

Constructors

Instance Method Summary

Constructor Detail

def self.new(api_app_id : String, channel_id : String, channel_name : String, command : String, response_url : String, team_id : String, text : String, trigger_id : String, user_id : String, user_name : String, enterprise_id : String | Nil = nil, enterprise_name : String | Nil = nil, team_name : String | Nil = nil) #

def self.new(pull : JSON::PullParser) #

[View source]

Instance Method Detail

def api_app_id : String #

def api_app_id=(api_app_id : String) #

def channel_id : String #

def channel_id=(channel_id : String) #

def channel_name : String #

def channel_name=(channel_name : String) #

def command : String #

def command=(command : String) #

def decoded_channels : Array(EncodedTextReference) #

Escaped channels may include the channel name and ID with a bar separator: <@C2147483705|channel-name>.


[View source]
def decoded_usernames : Array(EncodedTextReference) #

Escaped usernames in text will often be formatted with the user_id and the username encoded <@U012ABCDEF|worf>).

Slack is phasing these out, so apps should only rely on the ID, not the user_name + separator, long-term. Those that aren't being phased out are treated as "unreliable" -- meaning they change frequently and are mostly decorators.

More info available at Slack: The One About Usernames


[View source]
def enterprise_id : String | Nil #

def enterprise_id=(enterprise_id : String | Nil) #

def enterprise_name : String | Nil #

def enterprise_name=(enterprise_name : String | Nil) #

def plaintext_channels : Array(PlainTextReference) #

If an app is configured to not escape channels in text fields, the format channels will be presented as will be @channel, or @channel-with-dashes. A space signifies the end of a channel name.


[View source]
def plaintext_usernames : Array(PlainTextReference) #

If an app is configured to not escape usernames in text fields, the format usernames will be presented as will be @username, or @user_name for a user with a space in their username. A space signifies the end of a username.


[View source]
def response_url : String #

def response_url=(response_url : String) #

def team_id : String #

def team_id=(team_id : String) #

def team_name : String | Nil #

def team_name=(team_name : String | Nil) #

def text : String #

def text=(text : String) #

def trigger_id : String #

def trigger_id=(trigger_id : String) #

def user_id : String #

def user_id=(user_id : String) #

def user_name : String #

def user_name=(user_name : String) #