You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
619 B
PHP
27 lines
619 B
PHP
<?php
|
|
|
|
use Workerman\Worker;
|
|
use \Workerman\Lib\Timer;
|
|
use \Workerman\Lib\Tool;
|
|
|
|
$bot_loop = new Worker();
|
|
$bot_loop->count = 1;
|
|
$bot_loop->name = "每10秒自动触发";
|
|
$loop = 10;
|
|
$time = time() - $loop;
|
|
function BotFunc($loop, &$time)
|
|
{
|
|
if (time() - $time >= $loop) {
|
|
$res = Tool::post('http://code.dev.sa0.online:88/api/yo', []);
|
|
var_dump($res);
|
|
$time = $time + $loop;
|
|
}
|
|
}
|
|
|
|
$bot_loop->onWorkerStart = function () use ($loop, &$time) {
|
|
BotFunc($loop, $time);
|
|
Timer::add(2, function () use ($loop, &$time) {
|
|
BotFunc($loop, $time);
|
|
});
|
|
};
|