add prompt mode

This commit is contained in:
crazywhalecc
2023-01-08 16:43:30 +08:00
parent fe6c11b8af
commit 1487e1b216
4 changed files with 101 additions and 9 deletions

View File

@@ -4,13 +4,51 @@ declare(strict_types=1);
namespace ZM\Exception;
use OneBot\V12\Object\ActionResponse;
use OneBot\V12\Object\MessageSegment;
use OneBot\V12\Object\OneBotEvent;
class WaitTimeoutException extends ZMException
{
public $module;
private ?array $timeout_prompt;
public function __construct($module, $message = '', $code = 0, \Throwable $previous = null)
public function __construct(
public mixed $module,
string|\MessageSegment|array|\Stringable $timeout_prompt = '',
private ?ActionResponse $prompt_response = null,
private ?OneBotEvent $user_event = null,
private int $prompt_option = ZM_PROMPT_NONE,
\Throwable $previous = null
) {
parent::__construct('wait timeout!', 0, $previous);
if ($timeout_prompt === '') {
$this->timeout_prompt = null;
} elseif ($timeout_prompt instanceof MessageSegment) {
$this->timeout_prompt = [$timeout_prompt];
} elseif (is_string($timeout_prompt) || $timeout_prompt instanceof \Stringable) {
$this->timeout_prompt = [strval($timeout_prompt)];
} else {
$this->timeout_prompt = $timeout_prompt;
}
}
public function getTimeoutPrompt(): ?array
{
parent::__construct($message, $code, $previous);
$this->module = $module;
return $this->timeout_prompt;
}
public function getPromptResponse(): ?ActionResponse
{
return $this->prompt_response;
}
public function getUserEvent(): ?OneBotEvent
{
return $this->user_event;
}
public function getPromptOption(): int
{
return $this->prompt_option;
}
}