mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-22 16:15:34 +08:00
prerelease of beta1
This commit is contained in:
@@ -6,11 +6,11 @@ use OneBot\Driver\Coroutine\Adaptive;
|
||||
use OneBot\Driver\Coroutine\CoroutineInterface;
|
||||
use OneBot\Driver\Process\ExecutionResult;
|
||||
use OneBot\V12\Object\MessageSegment;
|
||||
use OneBot\V12\Object\OneBotEvent;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Container\Container;
|
||||
use ZM\Container\ContainerInterface;
|
||||
use ZM\Context\Context;
|
||||
use ZM\Logger\ConsoleLogger;
|
||||
use ZM\Middleware\MiddlewareHandler;
|
||||
use ZM\Store\Database\DBException;
|
||||
@@ -68,6 +68,9 @@ function zm_internal_errcode(int|string $code): string
|
||||
return "[ErrCode:{$code}] ";
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前炸毛实例的 ID
|
||||
*/
|
||||
function zm_instance_id(): string
|
||||
{
|
||||
if (defined('ZM_INSTANCE_ID')) {
|
||||
@@ -101,11 +104,6 @@ function is_assoc_array(array $array): bool
|
||||
return !empty($array) && array_keys($array) !== range(0, count($array) - 1);
|
||||
}
|
||||
|
||||
function ctx(): Context
|
||||
{
|
||||
return \container()->get('ctx');
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建消息段的助手函数
|
||||
*
|
||||
@@ -208,3 +206,13 @@ function config(array|string $key = null, mixed $default = null)
|
||||
}
|
||||
return $config->get($key, $default);
|
||||
}
|
||||
|
||||
function bot(): ZM\Context\BotContext
|
||||
{
|
||||
if (\container()->has('bot.event')) {
|
||||
/** @var OneBotEvent $bot_event */
|
||||
$bot_event = \container()->get('bot.event');
|
||||
return new \ZM\Context\BotContext($bot_event->self['user_id'] ?? '', $bot_event->self['platform']);
|
||||
}
|
||||
return new \ZM\Context\BotContext('', '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user