Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
DaisukeDaisuke authored Apr 23, 2020
1 parent 2d41d2c commit e0fc20a
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/pmmpDiscordBot/discordThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public function run(){
$send_channelId = $this->send_channelId;

$timer = $loop->addPeriodicTimer(2, function() use ($discord,$send_guildId,$send_channelId,$loop){
$this->task($discord,$send_guildId,$send_channelId,$loop);
$this->sendtask($discord,$send_guildId,$send_channelId,$loop);
});

$timer = $loop->addPeriodicTimer(0.05, function() use ($discord,$send_guildId,$send_channelId,$loop){
$this->checktask($discord,$send_guildId,$send_channelId,$loop);
});

$discord->on('ready', function($discord){
Expand Down Expand Up @@ -78,14 +82,8 @@ public function run(){
//var_dump("stop!!");
}

public function task($discord,$send_guildId,$send_channelId,$loop){
public function sendtask($discord,$send_guildId,$send_channelId,$loop){
if(!$this->started) return;
if($this->stopped){
$discord->close();
$loop->stop();
$this->started = false;
return;
}
$test = preg_replace(['/\]0;.*\%/','/[\x07]/',"/Server thread\//"],'',TextFormat::clean(substr($this->test,0,1900)));//processtile,ANSIコードの削除を実施致します...
$this->test = strlen($this->test) <= 1900 ? "" : substr($this->test,1900);//
if($test !== ""){
Expand All @@ -94,15 +92,24 @@ public function task($discord,$send_guildId,$send_channelId,$loop){
$channel->sendMessage("```\n".$test."\n```");
$this->test = "";
}
}

public function checktask($discord,$send_guildId,$send_channelId,$loop){
if(!$this->started) return;
if($this->stopped){
$discord->close();
$loop->stop();
$this->started = false;
return;
}

if(!$this->synchronized) return;

//ヒント: 101行付近より同期スレッド間データー受け渡しを実施しております...
//ヒント: 132行付近より同期スレッド間データー受け渡しを実施しております...
$this->synchronized(function() use ($discord){
$this->synchronized = false;
$this->wait();
});

}

//===メインスレッド呼び出し専用関数にてございます...===
Expand Down

0 comments on commit e0fc20a

Please sign in to comment.