☻ 唐鳳 ☺
and 1 contributors

NAME

Evalbot

DESCRIPTION

This is a small IRC bot using Net::IRC to eval() commands.

ARCHITECTURE

evalbot.pl is the main bot, written in Perl 6. To run a command, it spawns evalhelper-p5.pl, a Perl 5 program. This sets up the necessary environment (PUGS_SAFEMODE, redirection of STDOUT and STDERR to a temporary file, resource limits, etc.). Finally, evalhelper-p5.pl runs pugs.

INSTALLATION

There's no separate installation step needed, simply run evalbot.pl and supply a nick and an IRC server to connect to:

    $ pugs evalbot.pl evalbot6 irc.freenode.net:6667

You don't have to restart evalbot.pl when you install a new Pugs, as a new pugs is spawned on each command to eval.

evalhelper-p5.pl needs the BSD::Resource module to be able to set appropriate resource limits, so you can't run Evalbot under Win32.

REMOTE CONTROL

Once evalbot.pl is connected to IRC, everybody can send it expressions to eval:

    <you>     ?eval 42
    <evalbot> 42

Because of BSD::Resource and Pugs's safemode, Evalbot should be able to withstand most attacks (infinite loops, huge memory consumption, unsafe I/O, etc. etc.):

    <you>     ?eval while 1 {}
    <you>     ?eval my $str = "42" x 1_000_000_000_000
    <you>     ?eval system "rm -rf /"
    <you>     ?eval say "\nPRIVMSG foo :bar"
    <you>     ?eval say "flood\n" x 1_000
    # etc.

Note that the return value of an expression is not printed directly, but instead the .perl method is called to prettyprint the result:

    <you>     ?eval "hi"
    <evalbot> 'hi'              # (note that quotes)

This behaviour may be confusing at first, especially if you intended to use &say to output something:

    <you>     ?eval say "hi"
    <evalbot> hi Bool::True     # (the Bool::True is say("hi")'s return value)

There're other commands available, too:

    <you>     ?help
    <evalbot> evalbot6 -- ?help | ?quit [reason] | ?raw ...
            | ?join #chan | ?uptime | ?eval code

AUTHOR

Ingo Blechschmidt, <iblech@web.de>