prerelease of beta1

This commit is contained in:
crazywhalecc
2022-12-20 20:10:40 +08:00
parent 588fc919d9
commit 865c306e14
17 changed files with 589 additions and 43 deletions

View File

@@ -41,7 +41,7 @@ class AnnotationHandler
public function __construct(string $annotation_class)
{
$this->annotation_class = $annotation_class;
logger()->debug('开始分发注解 {annotation}', ['annotation' => $annotation_class]);
logger()->debug('声明注解分发器 {annotation}', ['annotation' => $annotation_class]);
}
/**
@@ -88,6 +88,7 @@ class AnnotationHandler
*/
public function handleAll(mixed ...$params)
{
logger()->debug('开始分发注解 ' . $this->annotation_class);
try {
// 遍历注册的注解
foreach ((AnnotationMap::$_list[$this->annotation_class] ?? []) as $v) {

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace ZM\Annotation\OneBot;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\AnnotationBase;
use ZM\Annotation\Interfaces\Level;
/**
* @Annotation
* @NamedArgumentConstructor()
* @Target("METHOD")
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class BotAction extends AnnotationBase implements Level
{
public function __construct(public string $action = '', public bool $need_response = false, public int $level = 20)
{
}
public function getLevel()
{
return $this->level;
}
public function setLevel($level)
{
$this->level = $level;
}
}

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace ZM\Annotation\OneBot;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\AnnotationBase;
use ZM\Annotation\Interfaces\Level;
/**
* Class BotActionResponse
* 机器人指令注解
*
* @Annotation
* @NamedArgumentConstructor()
* @Target("METHOD")
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class BotActionResponse extends AnnotationBase implements Level
{
public function __construct(public ?int $retcode = null, public int $level = 20)
{
}
public function getLevel()
{
return $this->level;
}
public function setLevel($level)
{
$this->level = $level;
}
}

View File

@@ -27,8 +27,20 @@ class BotCommand extends AnnotationBase implements Level
/**
* @param string[] $alias
*/
public function __construct(public $name = '', public $match = '', public $pattern = '', public $regex = '', public $start_with = '', public $end_with = '', public $keyword = '', public $alias = [], public $message_type = '', public $user_id = '', public $group_id = '', public $level = 20)
{
public function __construct(
public $name = '',
public $match = '',
public $pattern = '',
public $regex = '',
public $start_with = '',
public $end_with = '',
public $keyword = '',
public $alias = [],
public $detail_type = '',
public $user_id = '',
public $group_id = '',
public $level = 20
) {
}
public static function make(

View File

@@ -8,6 +8,7 @@ use Attribute;
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\AnnotationBase;
use ZM\Annotation\Interfaces\Level;
/**
* 机器人相关事件注解
@@ -17,20 +18,28 @@ use ZM\Annotation\AnnotationBase;
* @NamedArgumentConstructor()
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class BotEvent extends AnnotationBase
class BotEvent extends AnnotationBase implements Level
{
public function __construct(public ?string $type = null, public ?string $detail_type = null, public ?string $impl = null, public ?string $platform = null, public ?string $self_id = null, public ?string $sub_type = null)
public function __construct(public ?string $type = null, public ?string $detail_type = null, public ?string $sub_type = null, public int $level = 20)
{
}
public static function make(
?string $type = null,
?string $detail_type = null,
?string $impl = null,
?string $platform = null,
?string $self_id = null,
?string $sub_type = null
?string $sub_type = null,
int $level = 20,
): BotEvent {
return new static(...func_get_args());
}
public function getLevel(): int
{
return $this->level;
}
public function setLevel($level)
{
$this->level = $level;
}
}