Viewing topic:Php irc bot say name
Page:
1
07-08-2008 - 22:06
Here is my code
<html>
case ':!paste':
fputs($socket ,"PRIVMSG ".$ex[2].' '.$ex[4]."Please do not paste over 3 lines in here please use a no paste service like http://pastebin.comn"
;
break;
</html>
When i type !paste name it only says name when i say !paste it say the line but no name... Please help me!!!
<html>
case ':!paste':
fputs($socket ,"PRIVMSG ".$ex[2].' '.$ex[4]."Please do not paste over 3 lines in here please use a no paste service like http://pastebin.comn"
;break;
</html>
When i type !paste name it only says name when i say !paste it say the line but no name... Please help me!!!
09-08-2008 - 12:27
Thats the well known new line problem. 
C/P from the tutorial:
There are some problems with this though. But i will help you along the way, for i have done this a trillion times a few years ago. The problem is simple, when a command is given by the server it adds a newline, and carriage return with it. (not always the carriage return) So when you are checking a command, and it is the last word from this line, it has the newline after it.
This gives the following problem. When you want to check the word for a command, and you will simply use the if() function it won't work. This is because !command is not the same as !commandn for example. So we first have to strip the word we want to check from the newline and carriage return.
This is very simple though
What this does, is replacing an array of both newline, and carriage return with nothing. An saves that word in the $command variable. The chr() function returns an ASCII value by giving it's number. Check this website for all ASCII numbers.
// So basically just run the str_replace line on your ex[4]

C/P from the tutorial:
There are some problems with this though. But i will help you along the way, for i have done this a trillion times a few years ago. The problem is simple, when a command is given by the server it adds a newline, and carriage return with it. (not always the carriage return) So when you are checking a command, and it is the last word from this line, it has the newline after it.
This gives the following problem. When you want to check the word for a command, and you will simply use the if() function it won't work. This is because !command is not the same as !commandn for example. So we first have to strip the word we want to check from the newline and carriage return.
This is very simple though
| php | |
|
1 2 3 4 5 6 7 8 |
<?php case ':!paste': $ex4 = str_replace(array(chr(10), chr(13)), '', $ex[3]); fputs($socket ,"PRIVMSG ".$ex[2].' '.$ex4."Please do not paste over 3 lines in here please use a no paste service like http://pastebin.comn"); break; ?> |
What this does, is replacing an array of both newline, and carriage return with nothing. An saves that word in the $command variable. The chr() function returns an ASCII value by giving it's number. Check this website for all ASCII numbers.
// So basically just run the str_replace line on your ex[4]
10-08-2008 - 21:36
would you mind putting the code on here including the !paste cause i really know nothing about str_replace
13-08-2008 - 07:56
Page:
1
Reply to topic
Reply to topic

