Re-do the eval plugin - permit only bot owners.

This commit is contained in:
Robert Gerus 2014-03-25 07:08:58 +01:00
parent 04de76cc0c
commit 14b64e632d

View file

@ -1,22 +1,22 @@
include EventMachine::IRC::Commands include EventMachine::IRC::Commands
Client.register_trigger("PRIVMSG") { |msg| Client.register_trigger("PRIVMSG") { |msg|
message = msg[:params][1] if Config[:eval][:owners].include?(msg[:prefix]) then
destination = msg[:params][0] message = msg[:params][1]
if message[0..5] == ":eval " then destination = msg[:params][0]
prog = message[6..-1] if message[0..5] == ":eval " then
puts "will try to eval: #{prog}" code = message[6..-1]
begin begin
retval = proc { retval = proc {
$SAFE = 4 eval(code)
eval(prog) }.call
}.call
Client.privmsg(destination, String.try_convert(retval.to_s)) Client.privmsg(destination, String.try_convert(retval.to_s))
rescue Exception => e rescue Exception => e
Client.privmsg(destination, e.inspect) Client.privmsg(destination, e.inspect)
puts e.inspect puts e.inspect
puts e.backtrace puts e.backtrace
end
end end
end end
} }