30 lines
1.0 KiB
Ruby
30 lines
1.0 KiB
Ruby
include EventMachine::IRC::Commands
|
|
|
|
Client.register_trigger("PRIVMSG", "eval") { |msg|
|
|
message = msg[:params][1]
|
|
destination = if msg[:params][0] == Config.lookup("client::nick", "repost", msg[:scope]) then
|
|
msg[:prefix].split("!").first
|
|
else
|
|
msg[:params][0]
|
|
end
|
|
|
|
if message[0..5] == ":eval " then
|
|
if Config.lookup("eval::owners", [], msg[:scope]).include?(msg[:scope]["person"]) then
|
|
code = message[6..-1]
|
|
begin
|
|
retval = proc {
|
|
eval(code)
|
|
}.call
|
|
|
|
Client.privmsg(destination, String.try_convert(retval.to_s) + " => " + retval.class.to_s)
|
|
rescue Exception => e
|
|
Client.privmsg(destination, e.inspect)
|
|
puts e.inspect
|
|
puts e.backtrace
|
|
end
|
|
else
|
|
Client.privmsg(destination, Config.lookup("commands::eval::denied", "go away!", msg[:scope]))
|
|
end
|
|
end
|
|
}
|