Support Forums

Full Version: [perl] IRC bot - insult user on join
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
this is just a short little IRC bot in perl to make people who just joined think that everyone else was making fun of them.


works something like this:
Quote:*stupid_noob have just joined #malvager
<gibson_h4x> And that's why stupid_noob's a fggot.
<stupid_noob> fudge you gibson_h4x


There's an exempt list, so I suggest you put your/your friend's nicks on the list so he's not calling you a friend all the time ;). You should also put the bot's nick on your exempt list. it'd be kind of obvious if every time he joined he called himself a friend.

Code:
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;


my $server = "irc.server.com";
my $nick = "nick";
my $login = "better_than_you";


my $channel = "#channel";

# exempt list:
my @Exempt = qw(your_nick friends_nick);


my $sock = new IO::Socket::INET(PeerAddr => $server,
                                PeerPort => 6667,
                                Proto => 'tcp') or
                                    die "Can't connect\n";


print $sock "NICK $nick\r\n";
print $sock "USER $login 8 * :Perl IRC Robot\r\n";


while (my $input = <$sock>) { # stole this loop from the internet.  I forget where, specifically, but I stole it.
    if ($input =~ /004/) {
        last;
    }
    elsif ($input =~ /433/) {
        die "Nickname is already in use.";
    }
    print $input;
}

print $sock "JOIN $channel\r\n";

while (chomp(my $input = <$sock>)) {    
    print "$input\n";
    if ($input =~ /^PING(.*)$/i) {

        print $sock "PONG $1\r\n";
    } elsif ($input =~ /^:(.*)!.* JOIN :$channel/i) {
        if(not_exempt($1)!= 1) {
            print $sock "PRIVMSG $channel And that's why $1's a fggot.\r\n";    
        }
    }

}

sub not_exempt() {
    my $nick = $_[0];
    foreach(@Exempt) {
        if($_ eq $nick) {
           return 1;
        }
    }
    return 0;
}
http://farout.pastebin.com/m2ee87bab

Although all it does right now is call people who aren't on the exempt list a fool, with some slight modification it could be turned into something useful. (i.e. op-ing members who are on the exempt list, giving voice to people who've just joined.)
Lol, that is funny thank you for the share :p
Lol, nice thanks for this share!
Ummm, any reason bumping a two year old thread?
lol using this right now