11import { Context , Service } from 'cordis'
22import { OB11Entities } from './entities'
3- import { FriendRequest , GroupNotify , GroupNotifyStatus , GroupNotifyType , RawMessage } from '../ntqqapi/types'
3+ import {
4+ ChatType ,
5+ FriendRequest ,
6+ GroupNotify ,
7+ GroupNotifyStatus ,
8+ GroupNotifyType ,
9+ JsonGrayTipBusId ,
10+ RawMessage ,
11+ } from '../ntqqapi/types'
412import { OB11GroupRequestEvent } from './event/request/OB11GroupRequest'
513import { OB11FriendRequestEvent } from './event/request/OB11FriendRequest'
614import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent'
@@ -19,9 +27,16 @@ import { OB11GroupIncreaseEvent } from './event/notice/OB11GroupIncreaseEvent'
1927import { FlashFileDownloadStatus , FlashFileUploadStatus } from '@/ntqqapi/types/flashfile'
2028import {
2129 OB11FlashFile ,
22- OB11FlashFileDownloadedEvent , OB11FlashFileDownloadingEvent ,
23- OB11FlashFileUploadedEvent , OB11FlashFileUploadingEvent ,
30+ OB11FlashFileDownloadedEvent ,
31+ OB11FlashFileDownloadingEvent ,
32+ OB11FlashFileUploadedEvent ,
33+ OB11FlashFileUploadingEvent ,
2434} from '@/onebot11/event/notice/OB11FlashFileEvent'
35+ import {
36+ OB11FriendPokeEvent ,
37+ OB11FriendPokeRecallEvent ,
38+ OB11GroupPokeRecallEvent ,
39+ } from '@/onebot11/event/notice/OB11PokeEvent'
2540
2641declare module 'cordis' {
2742 interface Context {
@@ -196,10 +211,33 @@ class OneBot11Adapter extends Service {
196211 peerUid : message . peerUid ,
197212 chatType : message . chatType ,
198213 }
214+ // 解析撤回戳一戳
215+ const grayTipElement = message . elements . find ( el => el . grayTipElement ) ?. grayTipElement
216+ if ( grayTipElement && grayTipElement . jsonGrayTipElement ?. busiId == JsonGrayTipBusId . Poke ) {
217+ const json = JSON . parse ( grayTipElement . jsonGrayTipElement . jsonStr )
218+ const templateParams = grayTipElement . jsonGrayTipElement ?. xmlToJsonParam ?. templParam
219+ const fromUserUin = templateParams ?. get ( 'uin_str1' ) || '0'
220+ const toUserUin = templateParams ?. get ( 'uin_str2' ) || '0'
221+ let recallEvent : OB11FriendPokeRecallEvent | OB11GroupPokeRecallEvent ;
222+ if ( peer . chatType === ChatType . Group ) {
223+ recallEvent = new OB11GroupPokeRecallEvent ( parseInt ( message . peerUid ) , parseInt ( fromUserUin ) , parseInt ( toUserUin ) , json )
224+ }
225+ else {
226+ recallEvent = new OB11FriendPokeRecallEvent ( parseInt ( fromUserUin ) , parseInt ( toUserUin ) , json )
227+ }
228+ return this . dispatch ( recallEvent )
229+ }
230+ // OB11Entities.privateEvent(this.ctx, message).then(privateEvent => {
231+ // if (privateEvent?.sub_type === 'poke') {
232+ // (privateEvent as OB11FriendPokeEvent).sub_type = 'poke_recall'
233+ // this.dispatch(privateEvent)
234+ // }
235+ // })
199236 const oriMessageId = this . ctx . store . getShortIdByMsgInfo ( peer , message . msgId )
200237 if ( ! oriMessageId ) {
201238 return
202239 }
240+
203241 OB11Entities . recallEvent ( this . ctx , message , oriMessageId ) . then ( ( recallEvent ) => {
204242 if ( recallEvent ) {
205243 this . dispatch ( recallEvent )
@@ -401,6 +439,19 @@ class OneBot11Adapter extends Service {
401439 const event = new OB11GroupDecreaseEvent ( tip . groupCode , userId , userId )
402440 this . dispatch ( event )
403441 }
442+ else if ( msgType === 528 && subType === 321 ) {
443+ // 私聊撤回戳一戳,不再从这里解析,应从 nt/message-deleted 事件中解析
444+ const fromUin : string = sysMsg . routingHead ?. fromUin . low
445+ const toUin : string = sysMsg . routingHead ?. toUin . low
446+ }
447+ else if ( msgType === 732 && subType === 21 ) {
448+ // 撤回群戳一戳,不再从这里解析,应从 nt/message-deleted 事件中解析
449+ const fromUin : string = sysMsg . routingHead ?. fromUin . low
450+ const toUin : string = sysMsg . routingHead ?. toUin . low // 这个一直都是bot uin
451+
452+ // 这是个 tlv 格式数据
453+ const content = sysMsg . body ?. msgContent
454+ }
404455 } )
405456
406457 this . ctx . on ( 'nt/flash-file-download-status' , input => {
0 commit comments