This commit is contained in:
idranme 2024-08-30 12:38:39 +08:00
parent 3e3f792035
commit bf17d46157
No known key found for this signature in database
GPG Key ID: 926F7B5B668E495F
2 changed files with 21 additions and 14 deletions

View File

@ -135,9 +135,8 @@ interface InvokeOptions<ReturnType> {
export function invoke< export function invoke<
R extends Awaited<ReturnType<NTService[S][M] extends (...args: any) => any ? NTService[S][M] : any>>, R extends Awaited<ReturnType<NTService[S][M] extends (...args: any) => any ? NTService[S][M] : any>>,
S extends keyof NTService = any, S extends keyof NTService = any,
M extends keyof NTService[S] & string = any, M extends keyof NTService[S] & string = any
O = string >(method: `${unknown extends `${S}/${M}` ? `${S}/${M}` : string}`, args?: unknown[], options: InvokeOptions<R> = {}) {
>(method: `${O extends `${S}/${M}` ? `${S}/${M}` : string}`, args?: unknown[], options: InvokeOptions<R> = {}) {
const className = options.className ?? NTClass.NT_API const className = options.className ?? NTClass.NT_API
const channel = options.channel ?? NTChannel.IPC_UP_2 const channel = options.channel ?? NTChannel.IPC_UP_2
const timeout = options.timeout ?? 5000 const timeout = options.timeout ?? 5000

View File

@ -127,32 +127,29 @@ class OneBot11Adapter extends Service {
} }
subType = 'kick' subType = 'kick'
} }
const groupDecreaseEvent = new OB11GroupDecreaseEvent( const event = new OB11GroupDecreaseEvent(
parseInt(notify.group.groupCode), parseInt(notify.group.groupCode),
parseInt(member1Uin), parseInt(member1Uin),
parseInt(operatorId), parseInt(operatorId),
subType, subType,
) )
this.dispatch(groupDecreaseEvent) this.dispatch(event)
} }
else if ([GroupNotifyType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS].includes(notify.type) && notify.status === GroupNotifyStatus.KUNHANDLE) { else if (notify.type === GroupNotifyType.REQUEST_JOIN_NEED_ADMINI_STRATOR_PASS && notify.status === GroupNotifyStatus.KUNHANDLE) {
this.ctx.logger.info('有加群请求') this.ctx.logger.info('有加群请求')
let requestUin = (await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)) const requestUin = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
if (isNaN(parseInt(requestUin))) { const event = new OB11GroupRequestEvent(
requestUin = (await this.ctx.ntUserApi.getUserDetailInfo(notify.user1.uid)).uin
}
const groupRequestEvent = new OB11GroupRequestEvent(
parseInt(notify.group.groupCode), parseInt(notify.group.groupCode),
parseInt(requestUin) || 0, parseInt(requestUin) || 0,
flag, flag,
notify.postscript, notify.postscript,
) )
this.dispatch(groupRequestEvent) this.dispatch(event)
} }
else if (notify.type === GroupNotifyType.INVITED_BY_MEMBER && notify.status === GroupNotifyStatus.KUNHANDLE) { else if (notify.type === GroupNotifyType.INVITED_BY_MEMBER && notify.status === GroupNotifyStatus.KUNHANDLE) {
this.ctx.logger.info('收到邀请我加群通知') this.ctx.logger.info('收到邀请我加群通知')
const userId = await this.ctx.ntUserApi.getUinByUid(notify.user2.uid) const userId = await this.ctx.ntUserApi.getUinByUid(notify.user2.uid)
const groupInviteEvent = new OB11GroupRequestEvent( const event = new OB11GroupRequestEvent(
parseInt(notify.group.groupCode), parseInt(notify.group.groupCode),
parseInt(userId) || 0, parseInt(userId) || 0,
flag, flag,
@ -160,7 +157,18 @@ class OneBot11Adapter extends Service {
undefined, undefined,
'invite' 'invite'
) )
this.dispatch(groupInviteEvent) this.dispatch(event)
}
else if (notify.type === GroupNotifyType.INVITED_NEED_ADMINI_STRATOR_PASS && notify.status === GroupNotifyStatus.KUNHANDLE) {
this.ctx.logger.info('收到群员邀请加群通知')
const userId = await this.ctx.ntUserApi.getUinByUid(notify.user1.uid)
const event = new OB11GroupRequestEvent(
parseInt(notify.group.groupCode),
parseInt(userId) || 0,
flag,
notify.postscript
)
this.dispatch(event)
} }
} catch (e: any) { } catch (e: any) {
this.ctx.logger.error('解析群通知失败', e.stack) this.ctx.logger.error('解析群通知失败', e.stack)