Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. // DEFINIMOS VARIABLES DE CONEXIÓN
  2. $servidor="irc.chathispano.com";
  3. $puerto="6667";
  4. $nick="BPI";
  5. $name="o";
  6. $canal="#ufc";
  7. $realname="no";
  8. $quit="no";
  9. $a = 0;
  10.  
  11. $CON[servidor]="irc.chathispano.com";
  12. $CON[puerto]="6667";
  13. $CON[nick]="BPI";
  14. $CON[name]="o";
  15. $CON[canal]="#ufc";
  16. $CON[realname]="no";
  17. $CON[quit] = "no";
  18. $CON[a] = 0;
  19.  
  20. set_time_limit(0);
  21.  
  22. // INICIAMOS LA CONEXIÓN SOCKET AL SERVIDOR
  23. $conexion = fsockopen($CON[servidor], $CON[puerto]);
  24.  
  25. if (!$conexion){
  26. echo "No se pudo conectar a $servidor por el puerto $puerto";
  27. }
  28. else {
  29. echo "conectando...\n\n";
  30. fputs($conexion, "nick $nick\n\n");
  31. fputs($conexion, "USER $nick BPI BPI :$CON[name]\n\n");
  32. }
  33.  
  34. // INICIAMOS EL BUCLE QUE LEERA CONSTANTEMENTE DEL SERVIDOR Y LO ALMACENARA EN LA VARIABLE $buffer HASTA UN EOF.
  35. while (!feof($conexion)){
  36.  
  37. $buffer = trim(fgets($conexion, 4096));
  38. print date("[d/m @ H:i]")."<- ".$buffer ."\n"; // IMPRIMIMOS EN PANTALLA EL CONTENIDO DE $buffer. (se puede prescindir de esto)
  39.  
  40. // RECOGEMOS NÚMERO DE PING
  41. if(substr($buffer, 0, 6) == 'PING :') {
  42. // ENVIAMOS NUESTRO PONG
  43. fputs($conexion, 'PONG :'. substr($buffer, 6)."\n\n");
  44.  
  45. /* llegados a este punto ya esta establecida la conexión, ahora para saber si acaba de acceder al servidor usamos la variable $a = 0;, si $a vale 0 entrara en el canal e incrementaremos $a++ para que $a no sea igual a 0 y no vuelva a intentar acceder al canal*/
  46. if ($CON[a] == 0){
  47. fputs($conexion, "JOIN $CON[canal]\n\n");
  48. $CON[a]++;
  49. }
  50. registro ($buffer);
  51. }
  52. elseif ($old_buffer != $buffer) {
  53.  
  54. // LLEGADOS A ESTE PUNTO PODEMOS DEFINIR NUESTRAS ORDENES PARA EL BOT.
  55. if (eregi("!time",$buffer) && substr($buffer, 0, 11) == ":^Galactus^") {
  56. fputs($conexion,"privmsg $canal :time -> ".date("H:i:s",time())."\n\n"); }
  57.  
  58. if (eregi("!ver",$buffer) && substr($buffer, 0, 11) == ":^Galactus^") {
  59. fputs($conexion,"privmsg $canal :pruebas de phph\n\n"); }
  60.  
  61. }
  62. }
  63. //para guardar el whois
  64. case 'join':
  65. $user = $matches['1'];
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement