Skip to content

Commit

Permalink
Merge pull request #108 from wanxger/master
Browse files Browse the repository at this point in the history
feat: add processInNotDefinedEvent
  • Loading branch information
Javen205 authored Apr 21, 2024
2 parents f3e3d5e + dd3e1f3 commit 4bbb8fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/commons/src/MsgAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { InComponentVerifyTicket } from './entity/msg/in/InComponentVerifyTicket
import { InAuthMpEvent } from './entity/msg/in/InAuthMpEvent'
import { InMassEvent } from './entity/msg/in/event/InMassEvent'
import { InWxVerifyDispatchEvent } from './entity/msg/in/event/InWxVerifyDispatchEvent'
import { InNotDefinedEvent } from './entity/msg/in/event/InNotDefinedEvent'

/**
* @author Javen
Expand All @@ -57,6 +58,8 @@ export interface MsgAdapter {
processInSpeechRecognitionResults(inSpeechRecognitionResults: InSpeechRecognitionResults): Promise<OutMsg>
// 处理未定义的消息(其他消息...该扩展了)
processIsNotDefinedMsg(inNotDefinedMsg: InNotDefinedMsg): Promise<OutMsg>
// 处理未定义的事件
processInNotDefinedEvent(inNotDefinedMsg: InNotDefinedEvent): Promise<OutMsg>
// 处理关注、取消关注事件
processInFollowEvent(inFollowEvent: InFollowEvent): Promise<OutMsg>
// 处理扫码事件
Expand Down
8 changes: 7 additions & 1 deletion packages/wxcp/src/QyWeChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import {
InBatchJobResult,
InExternalContact,
InExternalContactEvent,
InRegisterCorp
InRegisterCorp,
InNotDefinedEvent
} from '@tnwx/commons'

import { Kits } from '@tnwx/kits'
Expand Down Expand Up @@ -187,6 +188,11 @@ export class QyWeChat {
console.debug(`未能识别的消息类型。消息 xml 内容为:\n ${result}`)
}
outMsg = await msgAdapter.processIsNotDefinedMsg(<InNotDefinedMsg>inMsg)
} else if (inMsg instanceof InNotDefinedEvent) {
if (QyApiConfigKit.isDevMode()) {
console.debug(`未能识别的事件类型。事件 xml 内容为:\n ${result}`)
}
outMsg = await msgAdapter.processInNotDefinedEvent(<InNotDefinedEvent>inMsg)
}

// 处理发送的消息
Expand Down
9 changes: 8 additions & 1 deletion packages/wxmp/src/WeChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
InComponentVerifyTicket,
InAuthMpEvent,
InMassEvent,
InWxVerifyDispatchEvent
InWxVerifyDispatchEvent,
InNotDefinedEvent
} from '@tnwx/commons'
import { Kits } from '@tnwx/kits'

Expand Down Expand Up @@ -167,6 +168,12 @@ export class WeChat {
console.debug(result)
}
outMsg = await msgAdapter.processIsNotDefinedMsg(<InNotDefinedMsg>inMsg)
} else if (inMsg instanceof InNotDefinedEvent) {
if (ApiConfigKit.isDevMode()) {
console.debug('未能识别的事件类型。 事件 xml 内容为:\n')
console.debug(result)
}
outMsg = await msgAdapter.processInNotDefinedEvent(<InNotDefinedEvent>inMsg)
}

// 处理发送的消息
Expand Down

0 comments on commit 4bbb8fd

Please sign in to comment.