Hayer Skrevet 1. mai 2008 Del Skrevet 1. mai 2008 Hei! Kan starte med å gi ut kildekoden min; Klikk for å se/fjerne innholdet nedenfor <?php set_time_limit(0); $irc = fsockopen("irc.quakenet.org",6777); sleep(5); if($irc == false) { die("Klarte ikke å koble til IRC-tjeneren."); } fputs($irc, "USER TestBot95 [email protected] CM :FNavnJa\n"); sleep(5); // fputs($irc, "NICK TestBot23\n"); sleep(5); fputs($irc, "JOIN #testp\n"); while(1) { while($data = fgets($irc,128)) { echo nl2br($data); flush(); $ex = explode(' ', $data); if($ex[0] == "PING") { fputs($irc, "PONG ".$ex[1]); } } } ?> Problemet er bare at jeg får denne feilmeldingen; Warning: fsockopen() [function.fsockopen]: unable to connect to irc.quakenet.org:6777 (Et tilkoblingsforsøk mislyktes fordi den tilkoblede parten ikke svarte på riktig måte etter en tidsperiode, eller den etablerte tilkoblingen mislyktes fordi den tilkoblede verten ikke svarte. ) in C:\xampp\htdocs\mirc\bot.php on line 4 Klarte ikke Ã¥ koble til IRC-tjeneren. Lenke til kommentar
Danny92 Skrevet 1. mai 2008 Del Skrevet 1. mai 2008 Jeg tror jeg fant noe intrisangt her, det er et irc script. Fant det på google, har ikke prøvd den men kanskje du kan få noe ut av det? irc.class: <?php class IRC{ var $server_host = "irc.brasirc.org"; var $server_chan = "#recife"; var $server_port = 6667; var $nick = 'igonildo'; var $server; function Comando($cmd){ fwrite($this->server['SOCKET'], $cmd, strlen($cmd)); //sends the command to the server echo "[SEND] $cmd <br>"; //displays it on the screen } function Entrar(){ set_time_limit(0); $this->server = array(); //we will use an array to store all the server data. //Open the socket connection to the IRC server $this->server['SOCKET'] = fsockopen($this->server_host, $this->server_port, $errno, $errstr, 2); if($this->server['SOCKET']) { //Ok, we have connected to the server, now we have to send the login commands. $this->Comando("PASS NOPASS\n\r"); //Sends the password not needed for most servers $this->Comando("NICK $this->nick\n\r"); //sends the nickname $this->Comando("USER $this->nick USING PHP IRC\n\r"); //sends the user must have 4 paramters while(!@feof($server['SOCKET'])) //while we are connected to the server { $this->server['READ_BUFFER'] = fgets($this->server['SOCKET'], 1024); //get a line of data from the server echo "[RECIVE] ".$this->server['READ_BUFFER']."<br>\n\r"; //display the recived data from the server /* IRC Sends a "PING" command to the client which must be anwsered with a "PONG" Or the client gets Disconnected */ //Now lets check to see if we have joined the server if(strpos($this->server['READ_BUFFER'], "422")) //422 is the message number of the MOTD for the server (The last thing displayed after a successful connection) { //If we have joined the server $this->Comando("JOIN $this->server_chan\n\r"); //Join the chanel } if(substr($this->server['READ_BUFFER'], 0, 6) == "PING :") //If the server has sent the ping command { $this->Comando("PONG :".substr($this->server['READ_BUFFER'], 6)."\n\r"); //Reply with pong //As you can see i dont have it reply with just "PONG" //It sends PONG and the data recived after the "PING" text on that recived line //Reason being is some irc servers have a "No Spoof" feature that sends a key after the PING //Command that must be replied with PONG and the same key sent. } flush(); //This flushes the output buffer forcing the text in the while loop to be displayed "On demand" } } } } ?> test.php: <?php require ("irc.class.php"); $irc = new IRC(); $irc->Entrar(); ?> Lenke til kommentar
Hayer Skrevet 1. mai 2008 Forfatter Del Skrevet 1. mai 2008 (endret) fant feilen min, servern pinget meg så 'ponget' jeg feil tilbake et lite spm til på kommandoen SAY ser det ut til at dataen bare samler seg opp. pga, hvis jeg tar say say part #testp så skriver den ut 11tekst herPRIVMSG #testp :tekst herPART #PART #testp Sorry de rare tegna, pga noNameScript Noen som har tips/løsning til dette? : ) Klikk for å se/fjerne innholdet nedenfor switch($ex[3]) { case ":DISCONNECT": fputs($socket, "DISCONNECT"); die("Disconnected"); break; case ":SAY": fputs($socket, "PRIVMSG #testp :tekst her"); break; case ":JOIN": fputs($socket, "JOIN #" . $ex[4]); break; case ":PART": fputs($socket, "PART #" . $ex[4]); break; case ":DEBUG": viewArray($ex); break; } Endret 1. mai 2008 av Hayer Lenke til kommentar
itsmebth Skrevet 1. mai 2008 Del Skrevet 1. mai 2008 Du kan se hvordan jeg har gjort det: http://code.google.com/p/itsbot/ Syntaksen for privmsg er: :Nick!RealName@Host PRIVMSG #Channel :Message Lenke til kommentar
Hayer Skrevet 1. mai 2008 Forfatter Del Skrevet 1. mai 2008 så jeg skal fylle ut den ? :s Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå