set container allows extended BotContext

This commit is contained in:
crazywhalecc 2023-01-13 14:18:05 +08:00
parent e3af231cc0
commit 2c7b4c79a1
No known key found for this signature in database
GPG Key ID: 3A96869D13956E98

View File

@ -19,7 +19,7 @@ class ContainerRegistrant
/**
* 应在收到 OneBot 事件时调用
*/
public static function registerOBEventServices(OneBotEvent $event): void
public static function registerOBEventServices(OneBotEvent $event, string $bot_context = BotContext::class): void
{
self::addServices([
OneBotEvent::class => $event,
@ -28,7 +28,7 @@ class ContainerRegistrant
if (isset($event->self['platform'])) {
self::addServices([
BotContext::class => DI\autowire(BotContext::class)->constructor(
BotContext::class => DI\autowire($bot_context)->constructor(
$event->self['user_id'] ?? '',
$event->self['platform'],
),