From 6f7bda3b4592059cede1505da95b88d1f46face0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E7=91=BE?= Date: Sat, 31 Aug 2024 14:15:18 +0800 Subject: [PATCH] fix: store --- src/core/karin/karin.ts | 5 ++++- src/core/plugin/base.ts | 13 ++++++++++--- src/types/event/event.ts | 10 +++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/core/karin/karin.ts b/src/core/karin/karin.ts index 0a514916..14191954 100644 --- a/src/core/karin/karin.ts +++ b/src/core/karin/karin.ts @@ -47,7 +47,7 @@ export const enum MiddlewareType { /** 回复消息前 */ ReplyMsg = 'replyMsg', /** 发送主动消息前 */ - SendMsg = 'sendMsg' + SendMsg = 'sendMsg', } export interface Options { @@ -109,10 +109,13 @@ export interface OptionsElement extends OptionsCommand { export class Karin extends Listeners { /** 是否启动 */ #start: boolean + /** 存储器 由开发者自行调用 */ + store: Map constructor () { super() this.#start = false + this.store = new Map() this.run() } diff --git a/src/core/plugin/base.ts b/src/core/plugin/base.ts index fac09aa5..2750b544 100644 --- a/src/core/plugin/base.ts +++ b/src/core/plugin/base.ts @@ -137,14 +137,18 @@ export class Plugin implements PluginType { } /** + * - 已废弃 请使用karin.ctx * - 构建上下文键 + * @deprecated */ conKey (): string { return `${this.e.isGroup ? `${this.e.group_id}.` : ''}` + (this.userId || this.e.user_id) } /** - * 设置上下文状态 + * - 已废弃 请使用karin.ctx + * - 设置上下文状态 + * @deprecated */ setContext ( /** @@ -178,7 +182,8 @@ export class Plugin implements PluginType { } /** - * 获取上下文状态 + * - 已废弃 请使用karin.ctx + * - 获取上下文状态 */ getContext (): stateArrType[string] { const key = this.conKey() @@ -186,7 +191,9 @@ export class Plugin implements PluginType { } /** - * 清除上下文状态 + * - 已废弃 请使用karin.ctx + * - 清除上下文状态 + * @deprecated */ finish () { const key = this.conKey() diff --git a/src/types/event/event.ts b/src/types/event/event.ts index 8b21b8c0..77b90cfe 100644 --- a/src/types/event/event.ts +++ b/src/types/event/event.ts @@ -18,7 +18,7 @@ export const enum EventType { /** * - 请求事件 */ - Request = 'request' + Request = 'request', } /** @@ -44,7 +44,7 @@ export const enum MessageSubType { /** * - 陌生人消息 */ - Stranger = 'stranger' + Stranger = 'stranger', } /** @@ -114,7 +114,7 @@ export const enum NoticeSubType { /** * - 群聊消息表情动态回应 */ - GroupMessageReaction = 'group_message_reaction' + GroupMessageReaction = 'group_message_reaction', } /** @@ -132,7 +132,7 @@ export const enum RequestSubType { /** * - 邀请入群 */ - InvitedGroup = 'invited_group' + InvitedGroup = 'invited_group', } /** @@ -251,7 +251,7 @@ export interface KarinEventType { /** * - 存储器 由开发者自行调用 */ - store: Map + store: Map /** * - 原始消息 */