diff --git a/packages/koishi-core/src/app.ts b/packages/koishi-core/src/app.ts index 967f304b76..703f2f70a6 100644 --- a/packages/koishi-core/src/app.ts +++ b/packages/koishi-core/src/app.ts @@ -359,6 +359,9 @@ export class App extends Context { const group = await this.database.observeGroup(meta.groupId, Array.from(groupFields)) Object.defineProperty(meta, '$group', { value: group, writable: true }) + // emit attach event + this.emitEvent(meta, 'attach-group', meta) + // ignore some group calls const isAssignee = !group.assignee || group.assignee === this.selfId const noCommand = group.flag & GroupFlag.noCommand @@ -377,6 +380,7 @@ export class App extends Context { // emit attach event this.emitEvent(meta, 'attach', meta) + this.emitEvent(meta, 'attach-user', meta) // ignore some user calls if (user.flag & UserFlag.ignore) return diff --git a/packages/koishi-core/src/context.ts b/packages/koishi-core/src/context.ts index 024916dc9c..f5b32ca364 100644 --- a/packages/koishi-core/src/context.ts +++ b/packages/koishi-core/src/context.ts @@ -294,7 +294,8 @@ export interface EventMap { 'lifecycle/connect' (meta: Meta<'meta_event'>): any 'before-user' (fields: Set, argv: ParsedCommandLine): any 'before-group' (fields: Set, argv: ParsedCommandLine): any - 'attach' (meta: Meta<'message'>): any + 'attach-user' (meta: Meta<'message'>): any + 'attach-group' (meta: Meta<'message'>): any 'send' (meta: Meta<'send'>): any 'before-send' (meta: Meta<'send'>): any 'before-command' (argv: ParsedCommandLine): any @@ -315,6 +316,9 @@ export interface EventMap { 'connect' (): any 'before-disconnect' (): any 'disconnect' (): any + + // TODO: deprecated events + 'attach' (meta: Meta<'message'>): any } export type Events = keyof EventMap