class RemoteModule

Public Class Methods

new() click to toggle source
# File lib/rbot/core/remote.rb, line 328
def initialize
  super
  @port = @bot.config['remote.port']
  @host = @bot.config['remote.host']
  @drb = nil
  begin
    start_service if @bot.config['remote.autostart']
  rescue => e
    error "couldn't start remote service provider: #{e.inspect}"
  end
end

Public Instance Methods

cleanup() click to toggle source
# File lib/rbot/core/remote.rb, line 350
def cleanup
  stop_service
  super
end
handle_start(m, params) click to toggle source
# File lib/rbot/core/remote.rb, line 355
def handle_start(m, params)
  if @drb
    rep = "remote service provider already running"
    rep << " on port #{@port}" if m.private?
  else
    begin
      start_service(@port)
      rep = "remote service provider started"
      rep << " on port #{@port}" if m.private?
    rescue
      rep = "couldn't start remote service provider"
    end
  end
  m.reply rep
end
remote_login(m, params) click to toggle source
# File lib/rbot/core/remote.rb, line 375
def remote_login(m, params)
  id = @bot.auth.remote_login(params[:botuser], params[:password])
  raise "login failed" unless id
  return id
end
remote_test(m, params) click to toggle source
# File lib/rbot/core/remote.rb, line 371
def remote_test(m, params)
  @bot.say params[:channel], "This is a remote test"
end
start_service() click to toggle source
# File lib/rbot/core/remote.rb, line 340
def start_service
  raise "Remote service provider already running" if @drb
  @drb = DRb.start_service("druby://#{@host}:#{@port}", @bot.remote_object)
end
stop_service() click to toggle source
# File lib/rbot/core/remote.rb, line 345
def stop_service
  @drb.stop_service if @drb
  @drb = nil
end