-
Notifications
You must be signed in to change notification settings - Fork 17
/
bot.IRC.pl
40 lines (39 loc) · 979 Bytes
/
bot.IRC.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/perl
use strict;
use warnings;
use IO::Socket::INET;
use constant PERL_EOL => "\n";
my $ARGC = @ARGV;
my $notice =
"~ IRC Bot
~ Call him with \@<nickname>. He will reply with love :3
~ Usage : ".$0." <host> <port> <channel> <nickname>
";
print $notice;
die() if($ARGC!=4);
# config connection
my($host, $port, $channel) = (
$ARGV[0],
$ARGV[1],
$ARGV[2] );
# config pseudo
my($username, $realname, $nickname) = (
"FuuBot",
"FuuBot",
$ARGV[3] );
# open socket
*SOCK = IO::Socket::INET->new (
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Type => SOCK_STREAM );
# IRC protocole (USER NICK PING PONG JOIN PRIVMSG)
print SOCK "USER $username $username $username $realname".PERL_EOL;
print SOCK "NICK $nickname".PERL_EOL;
while(<SOCK>) {
print $_;
print SOCK "PONG$1".PERL_EOL if(/^PING(.*)$/i);
print SOCK "JOIN ".$channel.PERL_EOL;
print SOCK "PRIVMSG ".$channel." Yes ! We can follow \@tfairane".PERL_EOL if(/[@]$nickname/i);
}
close(SOCK);