mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 15:45:36 +08:00
fix multiple prompt timer bug
This commit is contained in:
@@ -16,6 +16,7 @@ use ZM\Context\Trait\BotActionTrait;
|
||||
use ZM\Exception\OneBot12Exception;
|
||||
use ZM\Exception\WaitTimeoutException;
|
||||
use ZM\Plugin\OneBot12Adapter;
|
||||
use ZM\Schedule\Timer;
|
||||
use ZM\Utils\MessageUtil;
|
||||
|
||||
class BotContext implements ContextInterface
|
||||
@@ -114,14 +115,14 @@ class BotContext implements ContextInterface
|
||||
}
|
||||
$cid = $co->getCid();
|
||||
OneBot12Adapter::addContextPrompt($cid, $event);
|
||||
$co->create(function () use ($cid, $timeout) {
|
||||
Adaptive::sleep($timeout);
|
||||
$timer_id = zm_timer_after($timeout * 1000, function () use ($cid) {
|
||||
if (OneBot12Adapter::isContextPromptExists($cid)) {
|
||||
Adaptive::getCoroutine()->resume($cid, '');
|
||||
}
|
||||
});
|
||||
$result = $co->suspend();
|
||||
OneBot12Adapter::removeContextPrompt($cid);
|
||||
Timer::del($timer_id);
|
||||
if ($result === '') {
|
||||
throw new WaitTimeoutException(
|
||||
$this,
|
||||
|
||||
@@ -47,7 +47,7 @@ class Framework
|
||||
public const VERSION_ID = 689;
|
||||
|
||||
/** @var string 版本名称 */
|
||||
public const VERSION = '3.0.1';
|
||||
public const VERSION = '3.0.2';
|
||||
|
||||
/** @var array 传入的参数 */
|
||||
protected array $argv;
|
||||
|
||||
@@ -19,6 +19,11 @@ class Timer
|
||||
return Framework::getInstance()->getDriver()->getEventLoop()->addTimer($ms, $callback);
|
||||
}
|
||||
|
||||
public static function del(int $timer_id): void
|
||||
{
|
||||
Framework::getInstance()->getDriver()->getEventLoop()->clearTimer($timer_id);
|
||||
}
|
||||
|
||||
public static function registerTick(Tick $v): void
|
||||
{
|
||||
if ($v->class !== '' && $v->method !== '') {
|
||||
|
||||
Reference in New Issue
Block a user