Skip to content

Commit

Permalink
fix: icqq 私聊一条消息可能会多次触发事件
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Nov 8, 2023
1 parent 22d7434 commit ace74c0
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 32 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"assets"
],
"devDependencies": {
"@types/cli-progress": "^3.11.0",
"@types/cli-progress": "^3.11.5",
"@types/date-and-time": "^0.13.0",
"@types/fluent-ffmpeg": "^2.1.20",
"@types/lodash": "^4",
"@types/fluent-ffmpeg": "^2.1.24",
"@types/lodash": "^4.14.201",
"@types/node": "^18.6.3",
"@types/prompts": "^2.0.14",
"@types/prompts": "^2.4.8",
"@types/sharp": "^0.31.1",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
"typescript": "^5.2.2"
},
"dependencies": {
"@prisma/client": "5.5.2",
Expand All @@ -34,7 +34,7 @@
"eviltransform": "^0.2.2",
"file-type": "^17.1.4",
"fluent-ffmpeg": "^2.1.2",
"icqq": "^0.6.1",
"icqq": "^0.6.2",
"image-size": "^1.0.2",
"lodash": "^4.17.21",
"log4js": "^6.6.1",
Expand Down
57 changes: 32 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/controllers/ForwardController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ export default class ForwardController {
if (!pair) return;
if (!pair.enable) return;
if (pair.disableQ2TG) return;
// 如果是多张图片的话,是一整条消息,只过一次,所以不受这个判断影响
let existed = event.message_type === 'private' && await db.message.findFirst({
where: {
qqRoomId: pair.qqRoomId,
qqSenderId: event.sender.user_id,
seq: event.seq,
rand: event.rand,
pktnum: event.pktnum,
time: event.time,
instanceId: this.instance.id,
},
});
if (existed) return;
// 开始转发过程
let tgMessages: Api.Message | Api.Message[] = await this.forwardService.forwardFromQq(event, pair);
if (!tgMessages) return;
if (!Array.isArray(tgMessages)) {
Expand All @@ -57,7 +71,7 @@ export default class ForwardController {
await db.message.create({
data: {
qqRoomId: pair.qqRoomId,
qqSenderId: event.user_id,
qqSenderId: event.sender.user_id,
time: event.time,
brief: event.raw_message,
seq: event.seq,
Expand Down

0 comments on commit ace74c0

Please sign in to comment.