class SlackBotServer::RemoteControl

Send commands to a running SlackBotServer::Server instance

This should be initialized with a queue that is shared with the targetted server (e.g. the same local queue instance, or a redis queue instance that points at the same redis server).

Public Class Methods

new(queue:) click to toggle source

Create a new instance of a remote control @param queue [Object] any Object conforming to the queue API

(i.e. with #push and #pop methods)
# File lib/slack_bot_server/remote_control.rb, line 10
def initialize(queue:)
  @queue = queue
end

Public Instance Methods

add_bot(*args) click to toggle source

Sends an add_bot command to the {SlackBotServer::Server server}. See {SlackBotServer::Server#add_bot} for arguments.

# File lib/slack_bot_server/remote_control.rb, line 16
def add_bot(*args)
  @queue.push([:add_bot, *args])
end
broadcast(key, message_data) click to toggle source

Sends an broadcast command to the {SlackBotServer::Server server}. @param key [String] the key of the bot which should send the message @param message_data [Hash] passed directly to

{SlackBotServer::Bot#broadcast}; see there for argument details.
# File lib/slack_bot_server/remote_control.rb, line 30
def broadcast(key, message_data)
  @queue.push([:broadcast, key, message_data])
end
call(key, method, args) click to toggle source

Sends a message to be called directly on the slack web API. Generally for debugging only. @param key [String] the key of the bot which should send the message. @param method [String, Symbol] the name of the method to call @param args [Array] the arguments for the method to call

# File lib/slack_bot_server/remote_control.rb, line 57
def call(key, method, args)
  @queue.push([:call, [key, method, args]])
end
remove_bot(key) click to toggle source

Sends a remove_bot command to the server. @param key [String] the key of the bot to remove.

# File lib/slack_bot_server/remote_control.rb, line 22
def remove_bot(key)
  @queue.push([:remove_bot, key])
end
say(key, message_data) click to toggle source

Sends an say command to the {SlackBotServer::Server server}. @param key [String] the key of the bot which should send the message. @param message_data [Hash] passed directly to

{SlackBotServer::Bot#say}; see there for argument details.
# File lib/slack_bot_server/remote_control.rb, line 38
def say(key, message_data)
  @queue.push([:say, key, message_data])
end
say_to(key, user_id, message_data) click to toggle source

Sends an say_to command to the {SlackBotServer::Server server}. @param key [String] the key of the bot which should send the message. @param user_id [String] the Slack user ID of the person who should

receive the message.

@param message_data [Hash] passed directly to

{SlackBotServer::Bot#say_to}; see there for argument details.
# File lib/slack_bot_server/remote_control.rb, line 48
def say_to(key, user_id, message_data)
  @queue.push([:say_to, key, user_id, message_data])
end