mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: 独立窗口下撤回消息重复上报
This commit is contained in:
parent
712f0a8256
commit
2bfe9e236b
@ -151,18 +151,9 @@ function onLoad() {
|
|||||||
log(arg);
|
log(arg);
|
||||||
})
|
})
|
||||||
|
|
||||||
let postedMsgIds: Record<string, any> = {}
|
|
||||||
async function postReceiveMsg(msgList: RawMessage[]) {
|
async function postReceiveMsg(msgList: RawMessage[]) {
|
||||||
const {debug, reportSelfMessage} = getConfigUtil().getConfig();
|
const {debug, reportSelfMessage} = getConfigUtil().getConfig();
|
||||||
for (let message of msgList) {
|
for (let message of msgList) {
|
||||||
if (postedMsgIds[message.msgId]) { // 如果QQ开启了独立窗口,会导致消息重复上报,这里加个记录避免重复上报
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
postedMsgIds[message.msgId] = true
|
|
||||||
// 超过容量清空
|
|
||||||
if (Object.keys(postedMsgIds).length > 10000) {
|
|
||||||
postedMsgIds = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// log("收到新消息", message.msgId, message.msgSeq)
|
// log("收到新消息", message.msgId, message.msgSeq)
|
||||||
// if (message.senderUin !== selfInfo.uin){
|
// if (message.senderUin !== selfInfo.uin){
|
||||||
@ -200,7 +191,7 @@ function onLoad() {
|
|||||||
registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.UPDATE_MSG, async (payload) => {
|
registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.UPDATE_MSG, async (payload) => {
|
||||||
for (const message of payload.msgList) {
|
for (const message of payload.msgList) {
|
||||||
// log("message update", message.sendStatus, message.msgId, message.msgSeq)
|
// log("message update", message.sendStatus, message.msgId, message.msgSeq)
|
||||||
if (message.recallTime != "0") {
|
if (message.recallTime != "0") { //todo: 这个判断方法不太好,应该使用灰色消息元素来判断
|
||||||
// 撤回消息上报
|
// 撤回消息上报
|
||||||
const oriMessage = await dbUtil.getMsgByLongId(message.msgId)
|
const oriMessage = await dbUtil.getMsgByLongId(message.msgId)
|
||||||
if (!oriMessage) {
|
if (!oriMessage) {
|
||||||
@ -362,6 +353,7 @@ function onLoad() {
|
|||||||
let startTime = 0;
|
let startTime = 0;
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
|
log("llonebot pid", process.pid)
|
||||||
startTime = Date.now();
|
startTime = Date.now();
|
||||||
startReceiveHook().then();
|
startReceiveHook().then();
|
||||||
NTQQApi.getGroups(true).then()
|
NTQQApi.getGroups(true).then()
|
||||||
@ -428,6 +420,10 @@ function onLoad() {
|
|||||||
|
|
||||||
// 创建窗口时触发
|
// 创建窗口时触发
|
||||||
function onBrowserWindowCreated(window: BrowserWindow) {
|
function onBrowserWindowCreated(window: BrowserWindow) {
|
||||||
|
if (selfInfo.uid) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log("window create", window.webContents.getURL().toString())
|
||||||
try {
|
try {
|
||||||
hookNTQQApiCall(window);
|
hookNTQQApiCall(window);
|
||||||
hookNTQQApiReceive(window);
|
hookNTQQApiReceive(window);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user