summaryrefslogtreecommitdiffstats
path: root/plugins/eval.rb
blob: cfe21639e5afb5ee0634dbcfbcf53f7191223343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
include EventMachine::IRC::Commands

Client.register_trigger("PRIVMSG") { |msg|
    message = msg[:params][1]
    destination = msg[:params][0]

    if Config[:eval][:owners].include?(msg[:prefix]) then
        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
            end
        end
    else
        Client.privmsg(destination, Config[:eval][:denied])
    end
}