Пример #1
0
 public function run()
 {
     $socket = new sockets();
     $chatbot = new chatbot();
     $socket->onOpen(IP, PORT);
     $chatbot->sendLogin($socket->socket, USERNAME, PASSWORD);
     $chatbot->joinChannel($socket->socket, CHANNEL);
     while (true) {
         $socket->onMessage();
         //$chatbot->autotalk($socket->socket); // be carefully, the Bot goes crazy ;-)
     }
 }
Пример #2
0
 public function loadClientPacketsType($buffer)
 {
     //$clientpackets = new clientPackets();
     $chatbot = new chatbot();
     $type = unpack('c', $buffer);
     $cut = substr("{$buffer}", 3);
     $jsonDecode = json_decode($cut);
     switch ($type[1]) {
         case 1:
         case 2:
             // Update Players
             echo "Update Players \n";
             break;
         case 3:
             // Login ok
             echo "Login ok \n";
             break;
         case 4:
             // Login Failed
             echo "Login Failed \n";
             break;
         case 5:
             // Server Message
             $chatbot->ServerMessage($this->socket, $buffer);
             break;
         case 6:
         case 7:
         case 10:
             // Pong
         // Pong
         case 11:
             // RoomStart
         // RoomStart
         case 12:
             // UserList
             echo "Userlist:\n";
             break;
         case 13:
             // Update User Info
             echo "Update User Info:\n";
             break;
         case 16:
             // JoinChannelAccept
             echo "Join Channel Accept \n";
             break;
         case 17:
             // Message
             $chatbot->loadChatResponse($this->socket, $buffer);
             break;
         case 18:
             // Duel Request
             echo "DuelRequest: \n";
             $chatbot->DuelRequest($this->socket, $buffer);
             break;
         case 25:
             // Start Duel
             echo "startDuel: \n";
             // send Data to ygocore Server?
             //var_dump($jsonDecode);
             $chatbot->startDuel($this->socket, $jsonDecode->duelformatstring, $jsonDecode->server);
             break;
         case 37:
             // CreateRoom
             echo "CreateRoom:\n";
             break;
         case 39:
             // Update User Info
             echo "AddChannelUser:\n";
             echo $jsonDecode->Users[0]->username;
             echo "\n";
             $chatbot->autoKickUserFromChannel($this->socket, $jsonDecode->Users[0]->username);
             break;
         case 40:
             // Update User Info
             echo "RemoveChannelUser:\n";
             //echo $jsonDecode->Users[0]->username;
             echo "\n";
             break;
         case 42:
             // Invalid
             echo "Invalid: \n";
             break;
         default:
             echo "Type Detceted: " . $type[1] . " \n";
             break;
     }
 }