php irc bot

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

php irc bot

Post by toms100 »

well im trying to make one.
it can connect to server, but the server sends a ping command which requires a PONG to be sent back.. except i cant work out how to know when this is sent, and how to send back teh correct number
here is my code

Code: Select all

<?php
$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP); // create the socket 
$connection = socket_connect($socket,'irc.netgamers.org',6667); 
socket_write($socket,"USER RHAP RHAP RHAP :RHAP\r\n"); // Send the Username to 
socket_write($socket,"NICK c0wphpBot \r\n"); // Change our nickname 
socket_write($socket,"JOIN #php \r\n"); 
socket_write($socket,"MSG #php look this is c0ws scripit i wonder if it works\r\n"); // 
while($data = socket_read($socket,2046)) // read whatever IRC is telling us 
{ 
echo $data; 
} 
?>
i just got it froma tutorial
anyway when it connects this is printed out:
NOTICE AUTH :*** Looking up your hostname NOTICE AUTH :*** Checking Ident NOTICE AUTH :*** Couldn't look up your hostname PING :1757207385 :London.UK.Eu.Netgamers.org 451 c0wphpBot c0wphpBot :Register first. :London.UK.Eu.Netgamers.org 513 c0wphpBot :Your client may not be compatible with this server. :London.UK.Eu.Netgamers.org 513 c0wphpBot :Compatible clients are available at ftp://ftp.undernet.org/pub/irc/clients ERROR :Closing Link: c0wphpBot by London.UK.Eu.Netgamers.org (Ping Timeout)

it wants me to send PONG :1757207385 back to it
only i dont know how to check when i recieve the ping message!
if someone could help that would be cool

many thanks

Tom
User avatar
EvilWalrus
Site Admin
Posts: 209
Joined: Thu Apr 18, 2002 3:21 pm
Location: Springmont, PA USA

Post by EvilWalrus »

toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

wow, that is usefull, thanks:)
ill look through that and see how you do it, and try to make it possible in what i have!
i think ill make a class system for it as i might as well write something reusable
Post Reply