Ts3 php framework

Witam,
Mam pewien problem z botem do ts3, który jest bazowany na frameworku ts3 php framework. Od czasu do czasu gdy dana osoba wejdzie na serwer wyskakuje taki błąd:

[Dec 24 14:22:56] warning: [WelcomeMessage] ErrorID: 1538
Error Message: invalid parameter
Line: 319
File/opt/ts3phpbot/class/TeamSpeak3/Adapter/ServerQuery/Reply.php

Oto kod odpowiedzialny za wysyłanie wiadomości:

    public static function onClientEnter(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host, $AllClientInfo) {
    try {
         $serverData = $host->serverGetSelected();

         $dataArray = array(
        	'%VIRTUALSERVER_NAME%' => $serverData['virtualserver_name'],
        	'%VIRTUALSERVER_CLIENTSONLINE%' => $serverData['virtualserver_clientsonline'],
        	'%VIRTUALSERVER_MAXCLIENTS%' => $serverData['virtualserver_maxclients'],
        	'%VIRTUALSERVER_CHANNELSONLINE%' => $serverData['virtualserver_channelsonline'],
        	'%VIRTUALSERVER_MIN_CLIENTS_BEFORE_SILENCE%' => $serverData['virtualserver_min_clients_in_channel_before_forced_silence'],
        	'%VIRTUALSERVER_VERSION%' => $serverData['virtualserver_version'],
        	'%VIRTUALSERVER_CREATED%' => date('r', $serverData['virtualserver_created']),
        	'%VIRTUALSERVER_COMPLAIN_AUTO_BAN_COUNT%' => $serverData['virtualserver_complain_autoban_count'],
        	'%VIRTUALSERVER_COMPLAIN_AUTO_BAN_TIME%' => $serverData['virtualserver_complain_autoban_time'],
        	'%VIRTUALSERVER_COMPLAIN_REMOVE_TIME%' => $serverData['virtualserver_complain_remove_time'],
        	'%VIRTUALSERVER_QUERYCLIENTSONLINE%' => $serverData['virtualserver_queryclientsonline'],
        	'%VIRTUALSERVER_CONNECTION_PACKETS_SENT_TOTAL%' => $serverData['connection_packets_sent_total'],
        	'%VIRTUALSERVER_CONNECTION_BYTES_SENT_TOTAL%' => $serverData['connection_bytes_sent_total'],
        	'%VIRTUALSERVER_CONNECTION_PACKETS_RECEIVED_TOTAL%' => $serverData['connection_packets_received_total'],
        	'%VIRTUALSERVER_CONNECTION_BYTES_RECEIVED_TOTAL%' => $serverData['connection_bytes_received_total'],
        	'%BOT_NAME%' => System_Daemon::getOption('appName'),
        	'%BOT_VERSION%' => TS3Bot_Abstract::BOT_VERSION . ' [Build: ' . TS3Bot_Abstract::BOT_BUILD . ']',
        	'%CLIENT_CONNECTION_PACKETS_SENT_TOTAL%' => $AllClientInfo['connection_packets_sent_total'],
        	'%CLIENT_CONNECTION_BYTES_SENT_TOTAL%' => $AllClientInfo['connection_bytes_sent_total'],
        	'%CLIENT_CONNECTION_PACKETS_RECEIVED_TOTAL%' => $AllClientInfo['connection_packets_received_total'],
        	'%CLIENT_CONNECTION_BYTES_RECEIVED_TOTAL%' => $AllClientInfo['connection_bytes_received_total'],
        	'%CLIENT_NICKNAME%' => $AllClientInfo['client_nickname'],
        	'%CLIENT_LASTCONNECTED%' => date('r', $AllClientInfo['client_lastconnected']),
        	'%CLIENT_UNIQUE_IDENTIFIER%' => $AllClientInfo['client_unique_identifier']->toString(),
        	'%CLIENT_TOTAL_CONNECTIONS%' => $AllClientInfo['client_totalconnections']
        			);
        			$message = str_replace(array_keys($dataArray), array_values($dataArray), ModulesVariable::getWelcomeMessageVal());
        			$AllClientInfo->message(str_replace('', ' ', $message));
        		} catch(Exception $e) { 
        			$line = $e->getLine();
        			$code = $e->getCode();
        			$message = $e->getMessage();
        			self::warning("WelcomeMessage", "ErrorID: " . $code . "<br>Error Message: " . $message . "<br>Line: " . $line . "<br>File" . $e->getFile() . "<br>Trace: " . $e->getTrace());
        		}
    }

Połączenie z serwerem wygląda tak:

    		TeamSpeak3::init();
                    TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryConnected", array("TS3PHPBot", "onConnect"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyEvent", array("TS3PHPBot", "onEvent"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServerselected", array("TS3PHPBot", "onServerSelected"));				
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogin", array("TS3PHPBot", "onLogin"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyLogout", array("TS3PHPBot", "onLogout"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", array("TS3PHPBot", "onWaitTimeout"));		
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", array("TS3PHPBot", "onTextmessage"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyCliententerview", array("TS3PHPBot", "onClientEnter"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyClientleftview", array("TS3PHPBot", "onClientExit"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyChannelcreated", array("TS3PHPBot", "onChannelCreated"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyChanneledited", array("TS3PHPBot", "onChannelModified"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyChanneldeleted", array("TS3PHPBot", "onChannelDeleted"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyServeredited", array("TS3PHPBot", "onServerModified"));
    		TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyClientmoved", array("TS3PHPBot", "onClientMoved"));
    		
    		$connectStr = 'serverquery://' . self::$daemonConfig['TEAMSPEAK']['queryIP'] . ':' . self::$daemonConfig['TEAMSPEAK']['queryPort'] . '/';
    		$connectStr .= '?nickname=' . urlencode(self::$virtualServerConfig['CONFIG']['nickname']) . '&blocking=0&timeout=1#no_query_clients';
    		self::$serverInstance = TeamSpeak3::factory($connectStr);
    		self::$serverInstance->login(self::$daemonConfig['TEAMSPEAK']['user'], self::$daemonConfig['TEAMSPEAK']['password']);
    		$serverVersion = self::$serverInstance->version();
    		if ($serverVersion['build'] < '14468') {
    			self::emerg('You are using an outdated TeamSpeak 3 server. At least version 3.0.0-rc1 is required to run this daemon.');
    		}
    		self::$virtualHost = self::$serverInstance->serverGetByPort(self::$virtualServerConfig['CONFIG']['port']);
    		self::$daemonConfig = NULL;
    		self::$virtualServerConfig = NULL;
    		self::$virtualHost->notifyRegister("server");
    		self::$virtualHost->notifyRegister("channel");

    		while (!System_Daemon::isDying()) {
    			self::iterate();
    			self::$serverInstance->getAdapter()->wait();
    		}

To wina języka! Napisz w czymś innym niż w PHP, a będzie śmigało na 100%.

1 polubienie

@anon10657637 Skoro PHP jest beee to może polecisz jakąś sprawdzoną bibliotekę do obsługi TS3 na poziomie TS3 framework w innym języku? Z pewnością inni by skorzystali z takiej porady :slight_smile:

1 polubienie

Java


C#

1 polubienie

To pierwsze API to chyba przytoczyłeś dla jaj. Co prawda jest to jedyne publiczne API do javy, ale jest niestety z tego gorszego sortu API jakie widziałem. Niestety to API nie zalicza się do API na poziomie TS3 framework.

Wiem że nie jest doskonałe ale najbardziej popularne :slight_smile:
Ale jest jeszcze kilka zamienników
https://www.stefan1200.de/forum/index.php?topic=11.0
oraz

Nie żeby coś, ale nie porównuj php do Javy. To są dwa odrębne światy.

Sam nie lubie php. Mam swoje powody. Patrze na wygode funkcjonalnosci tych api do innych (oczywiscie w tym samym jezyku)