Skip to content

Commit a3ea394

Browse files
committed
chore: enhance error handling and user info retrieval in log and ntcall modules
1 parent 26f0a66 commit a3ea394

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

src/ntqqapi/api/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class NTQQUserApi extends Service {
5555
],
5656
{
5757
resultCmd: 'nodeIKernelProfileListener/onUserDetailInfoChanged',
58+
resultCb: payload => payload.simpleInfo.uid === uid,
5859
},
5960
)
6061
return result.simpleInfo

src/ntqqapi/log.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,17 @@ export async function logSummaryMessage(ctx: Context, message: RawMessage) {
5757
peerName = `群] ${message.peerName}(${message.peerUid}) ${sender}(${senderUin})`
5858
}
5959
else if (message.chatType == ChatType.C2C) {
60-
const senderInfo = (await ctx.ntUserApi.getUserDetailInfo(message.senderUid)).coreInfo
61-
sender = senderInfo.remark || senderInfo.nick
62-
peerName = `私] ${sender}(${senderUin})`
60+
try {
61+
const userUid = message.peerUid
62+
const userInfo = (await ctx.ntUserApi.getUserDetailInfo(userUid)).coreInfo
63+
sender = userInfo.remark || userInfo.nick
64+
peerName = `私] ${sender}(${userInfo.uin})`
65+
}catch (e) {
66+
return
67+
}
6368
}
6469
else if (message.chatType == ChatType.TempC2CFromGroup) {
65-
peerName = `临] ${sender}(${senderUin})`
70+
peerName = `临] ${message.peerName}(${message.peerUin})`
6671
}
6772
const padTime = (t: number) => t.toString().padStart(2, '0')
6873
const logMsg = `[${direction}-${peerName}:\n${summary}`

src/ntqqapi/ntcall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ export function invoke<
124124
removeReceiveHook(hookId)
125125
timeoutId && clearTimeout(timeoutId)
126126
})
127-
pmhq.call(funcName, args).then(r => firstResult = r)
127+
pmhq.call(funcName, args).then(r => firstResult = r).catch(reject)
128128
}
129129
else {
130130
pmhq.call(funcName, args).then(r=>{
131131
resolve(r)
132132
timeoutId && clearTimeout(timeoutId)
133-
})
133+
}).catch(reject)
134134
}
135135
})
136136
}

0 commit comments

Comments
 (0)