Class: Irc::Bot::RemoteObject
- Includes:
- DRbUndumped
- Defined in:
- lib/rbot/core/remote.rb
Overview
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
Instance Method Summary collapse
-
#delegate(session_id, *pars) ⇒ Object
The delegate method.
-
#initialize(bot) ⇒ RemoteObject
constructor
Initialization is simple.
Constructor Details
#initialize(bot) ⇒ RemoteObject
Initialization is simple
213 214 215 |
# File 'lib/rbot/core/remote.rb', line 213 def initialize(bot) @bot = bot end |
Instance Method Details
#delegate(session_id, *pars) ⇒ Object
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.
225 226 227 228 229 230 231 232 233 |
# 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 |