Support Forums
[perl] IRC bot - insult user on join - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Perl Programming Support (https://www.supportforums.net/forumdisplay.php?fid=31)
+---- Thread: [perl] IRC bot - insult user on join (/showthread.php?tid=3130)



[perl] IRC bot - insult user on join - wat - 11-24-2009

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.)


RE: [perl] IRC bot - insult user on join - Link - 06-19-2011

Lol, that is funny thank you for the share :p


RE: [perl] IRC bot - insult user on join - Slurms Makenzi - 06-24-2011

Lol, nice thanks for this share!


RE: [perl] IRC bot - insult user on join - old - 06-24-2011

Ummm, any reason bumping a two year old thread?


RE: [perl] IRC bot - insult user on join - Injection - 07-01-2011

lol using this right now