Class: Botiasloop::Commands::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/botiasloop/commands/context.rb

Overview

Context object passed to command executions Provides access to conversation, chat, config, channel, and user info

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conversation:, chat:, channel: nil, user_id: nil) ⇒ Context

Initialize context

Parameters:

  • conversation (Conversation)

    The current conversation

  • chat (Chat)

    The chat this conversation belongs to

  • channel (Channels::Base, nil) (defaults to: nil)

    The channel instance (nil in CLI)

  • user_id (String, nil) (defaults to: nil)

    The user/source identifier



26
27
28
29
30
31
# File 'lib/botiasloop/commands/context.rb', line 26

def initialize(conversation:, chat:, channel: nil, user_id: nil)
  @conversation = conversation
  @chat = chat
  @channel = channel
  @user_id = user_id
end

Instance Attribute Details

#channelChannels::Base? (readonly)

Returns The channel instance (nil in CLI).

Returns:



15
16
17
# File 'lib/botiasloop/commands/context.rb', line 15

def channel
  @channel
end

#chatChat (readonly)

Returns The chat this conversation belongs to.

Returns:

  • (Chat)

    The chat this conversation belongs to



12
13
14
# File 'lib/botiasloop/commands/context.rb', line 12

def chat
  @chat
end

#conversationConversation

Returns The current conversation.

Returns:



9
10
11
# File 'lib/botiasloop/commands/context.rb', line 9

def conversation
  @conversation
end

#user_idString? (readonly)

Returns The user/source identifier.

Returns:

  • (String, nil)

    The user/source identifier



18
19
20
# File 'lib/botiasloop/commands/context.rb', line 18

def user_id
  @user_id
end