May 02, 2005

Perl IRC bot one–liner

What can I say? I was bored. This can be run on compsoc's server, molotov:
perl -MNet::IRC -e'$i=new Net::IRC;$c=$i->newconn(Server,tov);$c->add_handler(376,\&o);$i->start;sub o{($s=shift)->join($b="#bots");$s->privmsg($b,Hi)}'

Of course, some would say that i should write it using raw sockets rather than Net::IRC, but it's proving a little tricky to fit on one line. I'll post it here if I manage it.

Note to self: Meeting about Union censorship, Tuesday (tomorrow), 6:15pm in R1.13.

EDIT: Oh, it doesn't work if your tov username is already being used as a nick on IRC. You need to change (Server,tov) to (Server,tov,Nick,Foo), where Foo is the desired username.

UPDATE: (2005–11-24) The following is slightly shorter, but adding NickServ support and !say might bloat it again.

perl -MNet::IRC -e'($i=new Net::IRC)->newconn(Server,tov)->add_handler(376,sub {($s=shift)->join($b="#bots");$s->privmsg($b,Hi)});$i->start'

- 8 comments by 1 or more people Not publicly viewable

[Skip to the latest comment]
  1. Terminal

    Nice!

    08 Aug 2005, 03:55

  2. krupt

    neat how about with socket?

    17 Sep 2005, 09:37

  3. link

    ;)

    17 Nov 2005, 21:53

  4. Heh, it doesn't meet your minimum entry requirements! I'm sure I could add !say… hmm…

    24 Nov 2005, 20:15

  5. Rael

    Any luck on the raw sockets? It wouldn't be a crime if you had to use, say 5 lines…

    25 Jan 2006, 02:29

  6. epoch

    #!/usr/bin/perl
    use IO'Socket;@ARGV<2&¨($v,$n,$c)=@ARGV;$s=new IO'Socket'INET
    "$v:6667"or die$@;print$s "user $n $n $n :n\r\nnick $n\r\n";
    while(){print;/^:(.+) [376|422]/&&print$s "join $c\r\n";
    /^PING/&&print$s "PONG $'\r\n";
    /^.!. .* (.) :!say (.)/&&print$s "privmsg 1 :2";}

    01 Apr 2006, 00:55

  7. Terminal

    haahhaha fuck u i made this bot u stole my idea from link fuck u all dont support him its my idea

    13 May 2006, 13:21

  8. c0rruptd1

    Terminal: haha to you sir, too bad your link is invalid and you're a liar. go troll somewhere else 14m3r

    26 May 2006, 20:44


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

This blog is obsolete

From 20th August 2007, this blog is no longer being updated. For something more recent, please visit Tim Retout’s website.

Search this blog

Not signed in
Sign in

Powered by BlogBuilder
© MMXIX