From 14b64e632dc864aba373a126a27d05a1d69c4244 Mon Sep 17 00:00:00 2001 From: Robert Gerus Date: Tue, 25 Mar 2014 07:08:58 +0100 Subject: [PATCH] Re-do the eval plugin - permit only bot owners. --- plugins/eval.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/eval.rb b/plugins/eval.rb index 769bc4d..4282f76 100644 --- a/plugins/eval.rb +++ b/plugins/eval.rb @@ -1,22 +1,22 @@ include EventMachine::IRC::Commands Client.register_trigger("PRIVMSG") { |msg| - message = msg[:params][1] - destination = msg[:params][0] - if message[0..5] == ":eval " then - prog = message[6..-1] - puts "will try to eval: #{prog}" - begin - retval = proc { - $SAFE = 4 - eval(prog) - }.call + if Config[:eval][:owners].include?(msg[:prefix]) then + message = msg[:params][1] + destination = msg[:params][0] + if message[0..5] == ":eval " then + code = message[6..-1] + begin + retval = proc { + eval(code) + }.call - Client.privmsg(destination, String.try_convert(retval.to_s)) - rescue Exception => e - Client.privmsg(destination, e.inspect) - puts e.inspect - puts e.backtrace + Client.privmsg(destination, String.try_convert(retval.to_s)) + rescue Exception => e + Client.privmsg(destination, e.inspect) + puts e.inspect + puts e.backtrace + end end end }