#-- vim:sw=2:et #++ # # :title: Script plugin for rbot # # Author:: Mark Kretschmann # Copyright:: (C) 2006 Mark Kretschmann # License:: GPL v2 # # Create mini plugins on IRC. # # Scripts are little Ruby programs that run in the context of the script # plugin. You can create them directly in an IRC channel, and invoke them just # like normal rbot plugins. define_structure :Command, :code, :nick, :created, :channel class ScriptPlugin < Plugin Config.register Config::IntegerValue.new('script.safe', :default => 3, :desc => 'configure $SAFE level for scripts (3=safe/tainted, 0=unsafe/ruby default)') def initialize super if @registry.has_key?(:commands) @commands = @registry[:commands] raise LoadError, "corrupted script database" unless @commands else @commands = Hash.new end end def save @registry[:commands] = @commands end def help( plugin, topic="" ) case topic when "add" "Scripts are little Ruby programs that run in the context of the script plugin. You can access @bot (class Irc::Bot), m (class Irc::PrivMessage), user (class String, either the first argument, or if missing the sourcenick), and args (class Array, an array of arguments). Example: 'script add greet m.reply( 'Hello ' + user )'. Invoke the script just like a plugin: ': greet'." when "allow" "script allow