Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Bot {
- private $_Socket;
- public function __construct($_CONFIG) {
- $this->_Socket = fsockopen($_CONFIG["server"], $_CONFIG["port"]);
- $this->send("NICK " . $_CONFIG["nick"]);
- $this->send("USER " . $_CONFIG["nick"] . " \"\" \"\" :token");
- print_r("Connected.\n");
- }
- public function read() {
- return trim(fgets($this->_Socket, 512));
- }
- public function message($target, $message) {
- return $this->send("PRIVMSG " . $target . " :" . $message);
- }
- public function part($channel) {
- return $this->send("PART " . $channel . " :Leaving.");
- }
- public function join($channel) {
- return $this->send("JOIN " . $channel);
- }
- public function pong($p) {
- return $this->send("PONG " . $p);
- }
- private function send($str) {
- fwrite($this->_Socket, $str . "\r\n");
- return 0;
- }
- private function cmd($str) {
- return $this->send("/ " , $str);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment