Class: SlackBot::Command

Inherits:
Object
  • Object
show all
Includes:
SlackBot::Concerns::InteractionKlass, SlackBot::Concerns::ViewKlass
Defined in:
lib/slack_bot/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SlackBot::Concerns::ViewKlass

included

Methods included from SlackBot::Concerns::InteractionKlass

included

Constructor Details

#initialize(current_user:, params:, args:, config: nil) ⇒ Command

Returns a new instance of Command.



10
11
12
13
14
15
16
17
# File 'lib/slack_bot/command.rb', line 10

def initialize(current_user:, params:, args:, config: nil)
  @current_user = current_user
  @params = params
  @config = config || SlackBot::Config.current_instance

  @args = SlackBot::Args.new
  @args.raw_args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



9
10
11
# File 'lib/slack_bot/command.rb', line 9

def args
  @args
end

#configObject (readonly)

Returns the value of attribute config.



9
10
11
# File 'lib/slack_bot/command.rb', line 9

def config
  @config
end

#current_userObject (readonly)

Returns the value of attribute current_user.



9
10
11
# File 'lib/slack_bot/command.rb', line 9

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params.



9
10
11
# File 'lib/slack_bot/command.rb', line 9

def params
  @params
end

Instance Method Details

#commandObject



19
20
21
# File 'lib/slack_bot/command.rb', line 19

def command
  params[:command]
end

#only_direct_message?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/slack_bot/command.rb', line 31

def only_direct_message?
  true
end

#only_slack_team?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/slack_bot/command.rb', line 35

def only_slack_team?
  true
end

#only_user?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/slack_bot/command.rb', line 27

def only_user?
  true
end

#render_response(response_type = nil, **kwargs) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/slack_bot/command.rb', line 39

def render_response(response_type = nil, **kwargs)
  return if !response_type

  {
    response_type: response_type
  }.merge(kwargs)
end

#textObject



23
24
25
# File 'lib/slack_bot/command.rb', line 23

def text
  params[:text]
end