mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: friend request flag invalid
This commit is contained in:
parent
23be081d29
commit
016482c9e5
src
@ -354,8 +354,9 @@ function onLoad() {
|
|||||||
|
|
||||||
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, async (payload) => {
|
registerReceiveHook<FriendRequestNotify>(ReceiveCmdS.FRIEND_REQUEST, async (payload) => {
|
||||||
for (const req of payload.data.buddyReqs) {
|
for (const req of payload.data.buddyReqs) {
|
||||||
if (req.isUnread && !friendRequests[req.sourceId] && (parseInt(req.reqTime) > startTime / 1000)) {
|
let flag = req.friendUid + req.reqTime;
|
||||||
friendRequests[req.sourceId] = req;
|
if (req.isUnread && (parseInt(req.reqTime) > startTime / 1000)) {
|
||||||
|
friendRequests[flag] = req;
|
||||||
log("有新的好友请求", req);
|
log("有新的好友请求", req);
|
||||||
let friendRequestEvent = new OB11FriendRequestEvent();
|
let friendRequestEvent = new OB11FriendRequestEvent();
|
||||||
try {
|
try {
|
||||||
@ -364,7 +365,7 @@ function onLoad() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("获取加好友者QQ号失败", e);
|
log("获取加好友者QQ号失败", e);
|
||||||
}
|
}
|
||||||
friendRequestEvent.flag = req.sourceId.toString();
|
friendRequestEvent.flag = flag;
|
||||||
friendRequestEvent.comment = req.extWords;
|
friendRequestEvent.comment = req.extWords;
|
||||||
postOB11Event(friendRequestEvent);
|
postOB11Event(friendRequestEvent);
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,10 @@ export class NTQQFriendApi{
|
|||||||
}, null]
|
}, null]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
static async handleFriendRequest(sourceId: number, accept: boolean,) {
|
static async handleFriendRequest(flag: string, accept: boolean,) {
|
||||||
const request: FriendRequest = friendRequests[sourceId]
|
const request: FriendRequest = friendRequests[flag]
|
||||||
if (!request) {
|
if (!request) {
|
||||||
throw `sourceId ${sourceId}, 对应的好友请求不存在`
|
throw `flat: ${flag}, 对应的好友请求不存在`
|
||||||
}
|
}
|
||||||
const result = await callNTQQApi<GeneralCallResult>({
|
const result = await callNTQQApi<GeneralCallResult>({
|
||||||
methodName: NTQQApiMethod.HANDLE_FRIEND_REQUEST,
|
methodName: NTQQApiMethod.HANDLE_FRIEND_REQUEST,
|
||||||
@ -54,7 +54,7 @@ export class NTQQFriendApi{
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
delete friendRequests[sourceId];
|
delete friendRequests[flag];
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export default class SetFriendAddRequest extends BaseAction<Payload, null> {
|
|||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
const approve = payload.approve.toString() === "true";
|
const approve = payload.approve.toString() === "true";
|
||||||
await NTQQFriendApi.handleFriendRequest(parseInt(payload.flag), approve)
|
await NTQQFriendApi.handleFriendRequest(payload.flag, approve)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user