This commit is contained in:
idranme
2024-09-21 03:30:01 +08:00
parent d8433e22d2
commit 390e20c2ef
5 changed files with 40 additions and 38 deletions

View File

@@ -111,7 +111,6 @@ export class NTQQGroupApi extends Service {
'nodeIKernelGroupService/getSingleScreenNotifies', 'nodeIKernelGroupService/getSingleScreenNotifies',
[{ doubt: false, startSeq: '', number: num }, null], [{ doubt: false, startSeq: '', number: num }, null],
{ {
cbCmd: ReceiveCmdS.GROUP_NOTIFY, cbCmd: ReceiveCmdS.GROUP_NOTIFY,
afterFirstCmd: false, afterFirstCmd: false,
} }
@@ -220,17 +219,7 @@ export class NTQQGroupApi extends Service {
} }
async getGroupRemainAtTimes(groupCode: string) { async getGroupRemainAtTimes(groupCode: string) {
return await invoke< return await invoke(NTMethod.GROUP_AT_ALL_REMAIN_COUNT, [{ groupCode }, null])
GeneralCallResult & {
atInfo: {
canAtAll: boolean
RemainAtAllCountForUin: number
RemainAtAllCountForGroup: number
atTimesMsg: string
canNotAtAllMsg: ''
}
}
>(NTMethod.GROUP_AT_ALL_REMAIN_COUNT, [{ groupCode }, null])
} }
async removeGroupEssence(groupCode: string, msgId: string) { async removeGroupEssence(groupCode: string, msgId: string) {
@@ -335,4 +324,13 @@ export class NTQQGroupApi extends Service {
} }
}, null]) }, null])
} }
async getGroupHonorList(groupCode: string) {
// 还缺点东西
return await invoke('nodeIKernelGroupService/getGroupHonorList', [{
req: {
groupCode: [+groupCode]
}
}, null])
}
} }

View File

@@ -11,16 +11,6 @@ declare module 'cordis' {
} }
} }
function generateMsgId() {
const timestamp = Math.floor(Date.now() / 1000)
const random = Math.floor(Math.random() * Math.pow(2, 32))
const buffer = Buffer.alloc(8)
buffer.writeUInt32BE(timestamp, 0)
buffer.writeUInt32BE(random, 4)
const msgId = BigInt('0x' + buffer.toString('hex')).toString()
return msgId
}
export class NTQQMsgApi extends Service { export class NTQQMsgApi extends Service {
static inject = ['ntUserApi'] static inject = ['ntUserApi']
@@ -102,7 +92,7 @@ export class NTQQMsgApi extends Service {
} }
async sendMsg(peer: Peer, msgElements: SendMessageElement[], timeout = 10000) { async sendMsg(peer: Peer, msgElements: SendMessageElement[], timeout = 10000) {
const msgId = generateMsgId() const msgId = await this.generateMsgUniqueId(peer.chatType)
peer.guildId = msgId peer.guildId = msgId
const data = await invoke<{ msgList: RawMessage[] }>( const data = await invoke<{ msgList: RawMessage[] }>(
'nodeIKernelMsgService/sendMsg', 'nodeIKernelMsgService/sendMsg',
@@ -275,4 +265,8 @@ export class NTQQMsgApi extends Service {
forceRefresh: true forceRefresh: true
}, null]) }, null])
} }
async generateMsgUniqueId(chatType: number) {
return await invoke('nodeIKernelMsgService/generateMsgUniqueId', [{ chatType }])
}
} }

View File

@@ -109,9 +109,9 @@ export class NTQQWebApi extends Service {
} }
//实现未缓存 考虑2h缓存 //实现未缓存 考虑2h缓存
async getGroupHonorInfo(groupCode: string, getType: WebHonorType) { async getGroupHonorInfo(groupCode: string, getType: string) {
const getDataInternal = async (Internal_groupCode: string, Internal_type: number) => { const getDataInternal = async (groupCode: string, type: number) => {
const url = 'https://qun.qq.com/interactive/honorlist?gc=' + Internal_groupCode + '&type=' + Internal_type.toString() const url = 'https://qun.qq.com/interactive/honorlist?gc=' + groupCode + '&type=' + type
let resJson let resJson
try { try {
const res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': cookieStr }) const res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': cookieStr })
@@ -119,7 +119,7 @@ export class NTQQWebApi extends Service {
if (match) { if (match) {
resJson = JSON.parse(match[1].trim()) resJson = JSON.parse(match[1].trim())
} }
if (Internal_type === 1) { if (type === 1) {
return resJson?.talkativeList return resJson?.talkativeList
} else { } else {
return resJson?.actorList return resJson?.actorList

View File

@@ -7,7 +7,20 @@ import {
import { GeneralCallResult } from './common' import { GeneralCallResult } from './common'
export interface NodeIKernelGroupService { export interface NodeIKernelGroupService {
getGroupHonorList(req: { groupCode: number[] }): unknown getGroupHonorList(req: { groupCode: number[] }): Promise<{
errCode: number
errMsg: string
groupMemberHonorList: {
honorList: {
groupCode: string
id: number[]
isGray: number
}[]
cacheTs: number
honorInfos: unknown[]
joinTime: number
}
}>
getUinByUids(uins: string[]): Promise<{ getUinByUids(uins: string[]): Promise<{
errCode: number errCode: number

View File

@@ -1,22 +1,19 @@
import { WebHonorType } from '@/ntqqapi/api'
import { ActionName } from '../types' import { ActionName } from '../types'
import { BaseAction } from '../BaseAction' import { BaseAction, Schema } from '../BaseAction'
interface Payload { interface Payload {
group_id: number group_id: number | string
type?: WebHonorType type: 'talkative' | 'performer' | 'legend' | 'strong_newbie' | 'emotion' | 'all'
} }
export class GetGroupHonorInfo extends BaseAction<Payload, unknown> { export class GetGroupHonorInfo extends BaseAction<Payload, unknown> {
actionName = ActionName.GetGroupHonorInfo actionName = ActionName.GetGroupHonorInfo
payloadSchema = Schema.object({
group_id: Schema.union([Number, String]).required(),
type: Schema.union(['talkative', 'performer', 'legend', 'strong_newbie', 'emotion', 'all']).default('all')
})
protected async _handle(payload: Payload) { protected async _handle(payload: Payload) {
if (!payload.group_id) {
throw '缺少参数group_id'
}
if (!payload.type) {
payload.type = WebHonorType.ALL
}
return await this.ctx.ntWebApi.getGroupHonorInfo(payload.group_id.toString(), payload.type) return await this.ctx.ntWebApi.getGroupHonorInfo(payload.group_id.toString(), payload.type)
} }
} }