Skip to content

Commit c572dfe

Browse files
committed
feat: ignore bots from auto download
1 parent 2fd5273 commit c572dfe

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/components/utils/message/download.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@ import fs from "fs";
44
import log from "../log";
55
import { addMessage } from "../../services/message";
66

7-
const PROJECT_AUTO_DOWNLOAD_MEDIA: boolean = process.env.PROJECT_AUTO_DOWNLOAD_MEDIA === "true"
7+
const PROJECT_AUTO_DOWNLOAD_MEDIA: boolean =
8+
process.env.PROJECT_AUTO_DOWNLOAD_MEDIA === "true";
89
const PROJECT_MAX_DOWNLOAD_MEDIA: number = parseInt(
910
process.env.PROJECT_MAX_DOWNLOAD_MEDIA || "25",
1011
);
1112
const MAX_FILE_SIZE: number = PROJECT_MAX_DOWNLOAD_MEDIA * 1024 * 1024;
1213

1314
export default async function (msg: Message): Promise<void> {
1415
// msg type unknown to ignore group mention statuses
15-
if (!msg.hasMedia || msg.fromMe || msg.type === "unknown" || !PROJECT_AUTO_DOWNLOAD_MEDIA) return;
16+
if (
17+
!msg.hasMedia ||
18+
msg.fromMe ||
19+
msg.type === "unknown" ||
20+
!PROJECT_AUTO_DOWNLOAD_MEDIA
21+
)
22+
return;
23+
24+
// ignore @Meta AI and others
25+
if (msg.author && msg.author.split("@")[1] === "bot") return;
26+
1627
const media = await msg.downloadMedia();
1728
if (!media) return;
1829

0 commit comments

Comments
 (0)