Skip to content

Commit

Permalink
fix: store
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Aug 31, 2024
1 parent 726a60e commit 6f7bda3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/core/karin/karin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const enum MiddlewareType {
/** 回复消息前 */
ReplyMsg = 'replyMsg',
/** 发送主动消息前 */
SendMsg = 'sendMsg'
SendMsg = 'sendMsg',
}

export interface Options {
Expand Down Expand Up @@ -109,10 +109,13 @@ export interface OptionsElement extends OptionsCommand {
export class Karin extends Listeners {
/** 是否启动 */
#start: boolean
/** 存储器 由开发者自行调用 */
store: Map<any, any>
constructor () {
super()

this.#start = false
this.store = new Map()
this.run()
}

Expand Down
13 changes: 10 additions & 3 deletions src/core/plugin/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
/**
Expand Down Expand Up @@ -178,15 +182,18 @@ export class Plugin implements PluginType {
}

/**
* 获取上下文状态
* - 已废弃 请使用karin.ctx
* - 获取上下文状态
*/
getContext (): stateArrType[string] {
const key = this.conKey()
return stateArr[key]
}

/**
* 清除上下文状态
* - 已废弃 请使用karin.ctx
* - 清除上下文状态
* @deprecated
*/
finish () {
const key = this.conKey()
Expand Down
10 changes: 5 additions & 5 deletions src/types/event/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const enum EventType {
/**
* - 请求事件
*/
Request = 'request'
Request = 'request',
}

/**
Expand All @@ -44,7 +44,7 @@ export const enum MessageSubType {
/**
* - 陌生人消息
*/
Stranger = 'stranger'
Stranger = 'stranger',
}

/**
Expand Down Expand Up @@ -114,7 +114,7 @@ export const enum NoticeSubType {
/**
* - 群聊消息表情动态回应
*/
GroupMessageReaction = 'group_message_reaction'
GroupMessageReaction = 'group_message_reaction',
}

/**
Expand All @@ -132,7 +132,7 @@ export const enum RequestSubType {
/**
* - 邀请入群
*/
InvitedGroup = 'invited_group'
InvitedGroup = 'invited_group',
}

/**
Expand Down Expand Up @@ -251,7 +251,7 @@ export interface KarinEventType {
/**
* - 存储器 由开发者自行调用
*/
store: Map<string, any>
store: Map<any, any>
/**
* - 原始消息
*/
Expand Down

0 comments on commit 6f7bda3

Please sign in to comment.