Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I need help bad :( I just want to make the bot issue USER cmd NICK cmd and join a channel then just reply to ping with pong that's it :( no luck will continue my search until I get some help....use Socket; use IO::Select; sub connec { my ($server,$port)=@_; $iaddr = inet_aton($server); $paddr = sockaddr_in($port,$iaddr); $proto = getprotobyname('tcp'); socket(SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket failed: $! +"; if (connect(SOCK,$paddr)) { print "Connected!\n"; } select(SOCK); $|=1; select(STDOUT); print SOCK "USER $botnick buf buf :$name\r\n"; print SOCK "NICK $botnick\r\n"; } sub getline { my $sck = IO::Select->new(); $sck->add(\*SOCK); while(1) { if ((@ready = $sck->can_read(5)) != 0) { foreach $handle (@ready) { if ($handle == \*SOCK) { if (sysread(SOCK,$inchar,1) > 0 ) { if ($inchar eq "\n") { chop $inline; return $inline; } } } } } } } while ($ircline=&getline){ ($pingchk,$rest)=split(/ /,$ircline,2); if ($pingchk eq 'PING') { print SOCK "PONG $rest"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl bot problems
by abstracts (Hermit) on Aug 10, 2001 at 23:37 UTC | |
by Anonymous Monk on Aug 10, 2001 at 23:58 UTC | |
by abstracts (Hermit) on Aug 11, 2001 at 00:11 UTC | |
|
Re: perl bot problems
by Bucket (Beadle) on Aug 10, 2001 at 23:36 UTC |