Class: Nanobot::Config::SlackConfig

Inherits:
Struct
  • Object
show all
Defined in:
lib/nanobot/config/schema.rb

Overview

Slack channel configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enabled: false, bot_token: nil, app_token: nil, group_policy: 'mention', group_allow_from: [], dm: {}) ⇒ SlackConfig

Returns a new instance of SlackConfig.

Parameters:

  • enabled (Boolean) (defaults to: false) —

    whether the Slack channel is active

  • bot_token (String, nil) (defaults to: nil) —

    Slack Bot User OAuth token (xoxb-)

  • app_token (String, nil) (defaults to: nil) —

    Slack App-Level token for Socket Mode (xapp-)

  • group_policy (String) (defaults to: 'mention') —

    group message policy: "mention" or "all"

  • group_allow_from (Array<String>) (defaults to: []) —

    allowed channel IDs for group messages

  • dm (Hash) (defaults to: {}) —

    direct message settings (see SlackDMConfig)



175
176
177
178
179
180
181
182
183
184
185
# File 'lib/nanobot/config/schema.rb', line 175

def initialize(
  enabled: false, bot_token: nil, app_token: nil,
  group_policy: 'mention', group_allow_from: [], dm: {}
)
  dm_config = dm.is_a?(Hash) ? dm : {}
  super(
    enabled: enabled, bot_token: bot_token, app_token: app_token,
    group_policy: group_policy, group_allow_from: group_allow_from,
    dm: SlackDMConfig.new(**dm_config)
  )
end

Instance Attribute Details

#app_token ⇒ Object

Returns the value of attribute app_token

Returns:

  • (Object) —

    the current value of app_token



165
166
167
# File 'lib/nanobot/config/schema.rb', line 165

def app_token
  @app_token
end

#bot_token ⇒ Object

Returns the value of attribute bot_token

Returns:

  • (Object) —

    the current value of bot_token



165
166
167
# File 'lib/nanobot/config/schema.rb', line 165

def bot_token
  @bot_token
end

#dm ⇒ Object

Returns the value of attribute dm

Returns:

  • (Object) —

    the current value of dm



165
166
167
# File 'lib/nanobot/config/schema.rb', line 165

def dm
  @dm
end

#enabled ⇒ Object

Returns the value of attribute enabled

Returns:

  • (Object) —

    the current value of enabled



165
166
167
# File 'lib/nanobot/config/schema.rb', line 165

def enabled
  @enabled
end

#group_allow_from ⇒ Object

Returns the value of attribute group_allow_from

Returns:

  • (Object) —

    the current value of group_allow_from



165
166
167
# File 'lib/nanobot/config/schema.rb', line 165

def group_allow_from
  @group_allow_from
end

#group_policy ⇒ Object

Returns the value of attribute group_policy

Returns:

  • (Object) —

    the current value of group_policy



165
166
167
# File 'lib/nanobot/config/schema.rb', line 165

def group_policy
  @group_policy
end