how do I get my irc bot to recieve commands from the server?
I have the following code but I don't get any responses from the server btw it's a unrealIRCd server and Im not using nickserv. is there any errors?
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"; }
}
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....
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.