#280 bots based on ts

This commit is contained in:
Ulf Gebhardt 2017-01-09 21:59:46 +01:00
parent 86c89a9530
commit b3eb6eb232
6 changed files with 73 additions and 14 deletions

@ -1 +1 @@
Subproject commit 27c4c21cd9463c005f7d6d61934de02e08101577
Subproject commit b6e32ac9717eb23b4b7677f57d380374de82cc77

View File

@ -0,0 +1,28 @@
<?php
class mojotrollz_tbc_soap {
private static function soap($port,$command){
$client = new SoapClient(NULL, array(
'location' => "http://127.0.0.1:$port/",
'uri' => 'urn:MaNGOS',
'style' => SOAP_RPC,
'login' => 'soap_gm',
'password' => 'algdc37avvjd',
));
return $client->executeCommand(new SoapParam($command, 'command'));
}
private static function soap_test($command){
return self::soap('7879', $command);}
private static function soap_live($command){
return self::soap('7878', $command);}
public static function test_bot_login($account,$character){
return self::soap_test('bot login '.$account.' '.$character);}
public static function bot_login($account,$character){
return self::soap('bot login '.$account.' '.$character);}
public static function test_bot_logout($account){
return self::soap_test('bot logout '.$account);}
public static function bot_logout($account){
return self::soap('bot logout '.$account);}
}

View File

@ -0,0 +1,18 @@
<?php
class cron_server_bot_tbc_live implements \SYSTEM\CRON\cronjob{
public static function run(){
\LIB\lib_ts3::php();
$ts3 = TeamSpeak3::factory("serverquery://mojotrollztsquery:9aYllYkG@127.0.0.1:10011/");
$bot_count = $ts3->serverGetByPort(9987)->clientCount();
$bots = \SQL\CRON_RANDOM_BOTS::QQ();
while($bot = $bots->next()){
if($bot_count > 0){
mojotrollz_tbc_soap::bot_login($bot['account_id'], $bot['char_id']);
$bot_count -= 1;
} else {
mojotrollz_tbc_soap::bot_logout($bot['account_id']);
}
}
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace SQL;
class CRON_RANDOM_BOTS extends \SYSTEM\DB\QQ {
public static function get_class(){return \get_class();}
public static function mysql(){return
'SELECT account_id, char_id FROM mojotrollz_bot'.
' WHERE server_id = 0'.
' ORDER BY RAND();';
}
}

View File

@ -73,9 +73,10 @@ class saimod_mojotrollz_server_tbc extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SAI_saimod_mojotrollz_server_tbc_action_bot_toggle($account, $guid, $server, $status){
if($status == 0){
\SQL\TBC_CHARACTER_BOT::QI(array($account,$guid,$server));
//\mojotrollz_tbc_soap::test_bot_login($account, $guid);
} else {
//TODO: Remove Bot from World
\SQL\TBC_CHARACTER_UNBOT::QI(array($account));
$server == 0 ? \mojotrollz_tbc_soap::bot_logout($account) : \mojotrollz_tbc_soap::test_bot_logout($account);
}
}

View File

@ -1,17 +1,19 @@
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_calculate_votes', 0, 0, 1, 0, 0, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_calculate_votes', 0, 0, 1, 0, 0, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_ts', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_ts', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_tbc', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_tbc_test', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_tbc', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_tbc_test', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_classic', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_classic_test', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_classic', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_players_online_classic_test', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_classic_realm', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_classic_world', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_classic_world_test', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_classic_realm', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_classic_world', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_classic_world_test', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_tbc_realm', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_tbc_world', NULL, NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_tbc_world_test', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_tbc_realm', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_tbc_world', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_online_tbc_world_test', NULL, NULL, NULL, NULL, NULL, NULL, 0);
REPLACE INTO `system_cron` (`class`, `min`, `hour`, `day`, `day_week`, `month`, `last_run`, `status`) VALUES ('cron_server_bot_tbc_live', NULL, NULL, NULL, NULL, NULL, NULL, 0);