Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[perl] IRC bot - insult user on join
#1
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.)
Reply
#2
Lol, that is funny thank you for the share :p
[Image: linksig.png]
AIM: Link0207 | MSN: Link0207@Link0207.com | YIM: Link0207
Reply
#3
Lol, nice thanks for this share!
[Image: Untitled-1-4.jpg]
Reply
#4
Ummm, any reason bumping a two year old thread?
Reply
#5
lol using this right now
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Join multiple lines based on pattern pr33 0 1,021 12-22-2014, 02:44 PM
Last Post: pr33
  Compile Error in Perl liveproject101 0 1,302 04-12-2013, 03:08 AM
Last Post: liveproject101
  [Perl] IRC Bot wchar_t 26 14,563 08-20-2012, 01:40 PM
Last Post: Trump
  Perl Ebook ven0m 2 1,825 05-04-2012, 08:14 AM
Last Post: ven0m
  Help with a program written in perl Rodman42866 1 1,684 03-09-2012, 03:16 AM
Last Post: AceInfinity

Forum Jump:


Users browsing this thread: 1 Guest(s)