Guest User

Untitled

a guest
Nov 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2. class Bot {
  3.  
  4. private $_Socket;
  5.  
  6. public function __construct($_CONFIG) {
  7. $this->_Socket = fsockopen($_CONFIG["server"], $_CONFIG["port"]);
  8. $this->send("NICK " . $_CONFIG["nick"]);
  9. $this->send("USER " . $_CONFIG["nick"] . " \"\" \"\" :token");
  10. print_r("Connected.\n");
  11. }
  12.  
  13. public function read() {
  14. return trim(fgets($this->_Socket, 512));
  15. }
  16.  
  17. public function message($target, $message) {
  18. return $this->send("PRIVMSG " . $target . " :" . $message);
  19. }
  20.  
  21. public function part($channel) {
  22. return $this->send("PART " . $channel . " :Leaving.");
  23. }
  24.  
  25. public function join($channel) {
  26. return $this->send("JOIN " . $channel);
  27. }
  28.  
  29. public function pong($p) {
  30. return $this->send("PONG " . $p);
  31. }
  32.  
  33. public function notice($to, $str) {
  34. print("NOTICE " . $to . " " . $str);
  35. return $this->send("NOTICE " . $to . " " . $str);
  36. }
  37.  
  38. private function send($str) {
  39. fwrite($this->_Socket, $str . "\r\n");
  40. return 0;
  41. }
  42. }
  43. ?>
Add Comment
Please, Sign In to add comment