# plugin. You can create them directly in an IRC channel, and invoke them just
# like normal rbot plugins.
-
-Command = Struct.new( "Command", :code, :nick, :created, :channel )
-
+define_structure :Command, :code, :nick, :created, :channel
class ScriptPlugin < Plugin
super
if @registry.has_key?(:commands)
@commands = @registry[:commands]
+ raise unless @commands
else
@commands = Hash.new
end
m.reply( e.inspect )
end
}
+ m.replied = true
end
end
def handle_eval( m, params )
code = params[:code].to_s.dup.untaint
- Thread.start {
- # TODO allow different safe levels for different botusers
- begin
- eval( code )
- rescue Exception => e
- m.reply( "Script '#{name}' crapped out :(" )
- m.reply( e.inspect )
- end
- }
+ Thread.start {
+ # TODO allow different safe levels for different botusers
+ begin
+ eval( code )
+ rescue Exception => e
+ m.reply( "Script '#{name}' crapped out :(" )
+ m.reply( e.inspect )
+ end
+ }
+ m.replied = true
end
def handle_echo( m, params )
code = params[:code].to_s.dup.untaint
- Thread.start {
- # TODO allow different safe levels for different botusers
- begin
- m.reply eval( code ).to_s
- rescue Exception => e
- m.reply( "Script '#{name}' crapped out :(" )
- m.reply( e.inspect )
- end
- }
+ Thread.start {
+ # TODO allow different safe levels for different botusers
+ begin
+ m.reply eval( code ).to_s
+ rescue Exception => e
+ m.reply( "Script '#{name}' crapped out :(" )
+ m.reply( e.inspect )
+ end
+ }
+ m.replied = true
end
command = Command.new( code, nick, created, channel )
@commands[name] = command
- m.reply( "done" )
+ m.okay
end
end
@commands.delete( name )
- m.reply( "done" )
+ m.okay
end