summaryrefslogtreecommitdiff
path: root/data/rbot/plugins
diff options
context:
space:
mode:
authorMatthias Hecker <apoc@geekosphere.org>2015-06-13 20:03:40 +0200
committerMatthias Hecker <apoc@geekosphere.org>2015-06-13 20:03:40 +0200
commit43ebe3abdcb86e0edebb2d581e07064df7fdf467 (patch)
treebf429261942bbf7362e542ec92219c6fa3fda9f1 /data/rbot/plugins
parent91b88cb3a769cc3b7ef97da9354aa1727caf3437 (diff)
script: make $SAFE configureable
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r--data/rbot/plugins/script.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb
index 0923dd5d..ccdf037d 100644
--- a/data/rbot/plugins/script.rb
+++ b/data/rbot/plugins/script.rb
@@ -17,6 +17,10 @@ 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)
@@ -68,8 +72,7 @@ class ScriptPlugin < Plugin
user = args.empty? ? m.sourcenick : args.first
Thread.start {
- # TODO allow different safe levels for different botusers
- $SAFE = 3
+ $SAFE = @bot.config['script.safe']
begin
eval( code )
@@ -105,7 +108,8 @@ class ScriptPlugin < Plugin
def handle_eval( m, params )
code = params[:code].to_s.dup.untaint
Thread.start {
- # TODO allow different safe levels for different botusers
+ $SAFE = @bot.config['script.safe']
+
begin
eval( code )
rescue Exception => e
@@ -119,7 +123,8 @@ class ScriptPlugin < Plugin
def handle_echo( m, params )
code = params[:code].to_s.dup.untaint
Thread.start {
- # TODO allow different safe levels for different botusers
+ $SAFE = @bot.config['script.safe']
+
begin
m.reply eval( code ).to_s
rescue Exception => e