Skip to content

Commit 7d480f3

Browse files
committed
feat: respect paused setting in event handlers
1 parent b194a9b commit 7d480f3

7 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/components/events/call.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ function getRandomResponse(arr: string[]) {
1212
export default async function (call: Call): Promise<void> {
1313
try {
1414
if (call.fromMe || call.isGroup) return;
15+
16+
const isPaused = await getSetting("paused");
17+
if (isPaused && isPaused === "on") return;
18+
1519
const isCallMustReject = await getSetting("call_reject");
1620
if (!isCallMustReject || isCallMustReject == "off") return;
1721

src/components/events/edit.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export default async function (
1515

1616
const lid = (msg.author ?? msg.from).split("@")[0];
1717

18+
const isPaused = await getSetting("paused");
19+
if (isPaused && isPaused === "on") return;
20+
1821
const [isBlocked, isMustResent] = await Promise.all([
1922
getBlockUser(lid),
2023
getSetting("resent_edit"),

src/components/events/groups/groupAdminChanged.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import sleep from "../../utils/sleep";
44
import { client } from "../../client";
55
import { getMessage } from "../../../data/group";
66
import * as Sentry from "@sentry/node";
7+
import { getSetting } from "../../services/settings";
78

89
export default async function (notif: GroupNotification): Promise<void> {
910
try {
1011
if (notif.timestamp < Date.now() / 1000 - 10) return;
12+
13+
const isPaused = await getSetting("paused");
14+
if (isPaused && isPaused === "on") return;
1115
} catch (err) {
1216
Sentry.captureException(err);
1317
log.error("GroupJoin", "Failed to process group admin changed event:", err);

src/components/events/groups/join.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ import { client } from "../../client";
55
import { getMessage } from "../../../data/group";
66
import * as Sentry from "@sentry/node";
77
import { PROJECT_CANIS_ALIAS } from "../../../config";
8+
import { getSetting } from "../../services/settings";
89

910
export default async function (notif: GroupNotification): Promise<void> {
1011
try {
1112
if (notif.timestamp < Date.now() / 1000 - 10) return;
13+
14+
const isPaused = await getSetting("paused");
15+
if (isPaused && isPaused === "on") return;
16+
1217
const group = await notif.getChat();
1318
const recipients = await notif.getRecipients();
1419
const text = `

src/components/events/groups/leave.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import sleep from "../../utils/sleep";
44
import { client } from "../../client";
55
import { getMessage } from "../../../data/group";
66
import * as Sentry from "@sentry/node";
7+
import { getSetting } from "../../services/settings";
78

89
export default async function (notif: GroupNotification): Promise<void> {
910
try {
1011
if (notif.timestamp < Date.now() / 1000 - 10) return;
12+
13+
const isPaused = await getSetting("paused");
14+
if (isPaused && isPaused === "on") return;
15+
1116
const group = await notif.getChat();
1217
const recipients = await notif.getRecipients();
1318

src/components/events/reaction.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export default async function (client: Client, react: Reaction): Promise<void> {
1717
// ignore @Meta AI and others
1818
if (react.senderId.split("@")[1] === "bot") return;
1919

20+
const isPaused = await getSetting("paused");
21+
if (isPaused && isPaused === "on") return;
22+
2023
const key = `react:${react.id.id}`;
2124
const alreadyReacted = await redis.get(key);
2225
if (alreadyReacted) return;

src/components/events/revoke.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export default async function (
1515

1616
const lid = (msg.author ?? msg.from).split("@")[0];
1717

18+
const isPaused = await getSetting("paused");
19+
if (isPaused && isPaused === "on") return;
20+
1821
const [isBlocked, isMustResent] = await Promise.all([
1922
getBlockUser(lid),
2023
getSetting("resent_unsent"),

0 commit comments

Comments
 (0)