Parent

Methods

Included Modules

Class/Module Index [+]

Quicksearch

Irc::Bot::RemoteObject

The Irc::Bot::RemoteObject class represents and object that will take care of interfacing with remote clients

Example client session:

require 'drb'
rbot = DRbObject.new_with_uri('druby://localhost:7268')
id = rbot.delegate(nil, 'remote login someuser somepass')[:return]
rbot.delegate(id, 'some secret command')

Of course, the remote login is only neede for commands which may not be available to everyone

Public Class Methods

new(bot) click to toggle source

Initialization is simple

# File lib/rbot/core/remote.rb, line 213
def initialize(bot)
  @bot = bot
end

Public Instance Methods

delegate(session_id, *pars) click to toggle source

The delegate method. This is the main method used by remote clients to send commands to the bot. Most of the time, the method will be called with only two parameters (session id and a String), but we allow more parameters for future expansions.

The session_id can be nil, meaning that the remote client wants to work as an anoynomus botuser.

# File lib/rbot/core/remote.rb, line 225
def delegate(session_id, *pars)
  warn "Ignoring extra parameters" if pars.length > 1
  cmd = pars.first
  client = @bot.auth.remote_user(session_id)
  raise "No such session id #{session_id}" unless client
  debug "Trying to dispatch command #{cmd.inspect} from #{client.inspect} authorized by #{session_id.inspect}"
  m = RemoteMessage.new(@bot, client, cmd)
  @bot.remote_dispatcher.handle(m)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.