Guest User

Untitled

a guest
Nov 25th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. class Bot {
  4.  
  5.  
  6.  
  7. private $_Socket;
  8.  
  9.  
  10.  
  11. public function __construct($_CONFIG) {
  12.  
  13. $this->_Socket = fsockopen($_CONFIG["server"], $_CONFIG["port"]);
  14.  
  15. $this->send("NICK " . $_CONFIG["nick"]);
  16.  
  17. $this->send("USER " . $_CONFIG["nick"] . " \"\" \"\" :token");
  18.  
  19. print_r("Connected.\n");
  20.  
  21. }
  22.  
  23.  
  24.  
  25. public function read() {
  26.  
  27. return trim(fgets($this->_Socket, 512));
  28.  
  29. }
  30.  
  31.  
  32.  
  33. public function message($target, $message) {
  34.  
  35. return $this->send("PRIVMSG " . $target . " :" . $message);
  36.  
  37. }
  38.  
  39.  
  40.  
  41. public function part($channel) {
  42.  
  43. return $this->send("PART " . $channel . " :Leaving.");
  44.  
  45. }
  46.  
  47.  
  48.  
  49. public function join($channel) {
  50.  
  51. return $this->send("JOIN " . $channel);
  52.  
  53. }
  54.  
  55.  
  56.  
  57. public function pong($p) {
  58.  
  59. return $this->send("PONG " . $p);
  60.  
  61. }
  62.  
  63.  
  64.  
  65. private function send($str) {
  66.  
  67. fwrite($this->_Socket, $str . "\r\n");
  68.  
  69. return 0;
  70.  
  71. }
  72.  
  73. private function cmd($str) {
  74. return $this->send("/ " , $str);
  75. }
  76.  
  77. }
  78.  
  79. ?>
Add Comment
Please, Sign In to add comment