Skip to content

Commit e2a9e49

Browse files
committed
chore: bug fixes
1 parent 5def3a4 commit e2a9e49

7 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/components/events/call.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ export default async function (call: Call): Promise<void> {
2727

2828
(await client()).sendMessage(call.from, response);
2929

30-
log.info(
31-
"CallEvent",
32-
`Rejected a ${call.isVideo ? "video" : "voice"} call from ${call.from}`,
33-
);
30+
log.info("Call", call.from, call.isVideo ? "video" : "voice");
3431
} catch (err) {
3532
Sentry.captureException(err);
3633
log.error("Error handling call:", err);

src/components/events/edit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default async function (
2020
getSetting("resent_edit"),
2121
]);
2222

23-
log.info("EditMessage", lid, prevBody);
23+
log.info("EditMessage", lid);
2424
await addMessage(lid, prevBody, "edit");
2525

2626
if (!isBlocked || !isMustResent || isMustResent == "off") return;

src/components/events/groups/join.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export default async function (notif: GroupNotification): Promise<void> {
3030
const isSelf =
3131
contact.id._serialized === (await client()).info.wid._serialized;
3232

33-
log.info("GroupJoin", `${name} joined the group ${group.name}`);
34-
3533
if (isSelf) {
3634
await notif.reply(text);
3735
} else {
@@ -40,6 +38,8 @@ export default async function (notif: GroupNotification): Promise<void> {
4038
}
4139
}
4240

41+
log.info("GroupJoin", group.id.user, JSON.stringify(newMembers));
42+
4343
await Promise.allSettled([
4444
(async () => {
4545
if (newMembers.length == 0) return;

src/components/events/groups/leave.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,21 @@ export default async function (notif: GroupNotification): Promise<void> {
1919
const isSelf =
2020
contact.id._serialized === (await client()).info.wid._serialized;
2121
if (!isSelf) {
22-
log.info("GroupLeave", `${name} left the group ${group.name}`);
2322
leavers.push(contact.id._serialized.split("@")[0]);
2423
mentionIds.push(contact.id._serialized);
2524
} else {
26-
log.info("GroupLeave", `the bot left the group ${group.name}`);
2725
break;
2826
}
2927
}
3028

29+
log.info("GroupLeave", group.id.user, JSON.stringify(leavers));
30+
3131
if (leavers.length == 0) return;
3232
const message = getMessage(
3333
"leaving",
3434
leavers.map((n) => `@${n}`).join(", "),
3535
);
3636

37-
// await notif.reply(getMessage("leaving", `*${leavers.join(", ")}*`));
3837
(await client()).sendMessage(notif.chatId, message, {
3938
mentions: mentionIds,
4039
});

src/components/events/message.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ export default async function (msg: Message, type: string): Promise<void> {
152152
await sleep(randomMs);
153153
const isEmoji = /.*[A-Za-z0-9].*/.test(reaction);
154154
log.info("AutoReact", lid, reaction);
155+
await redis.set(`react:${msg.id.id}`, "1", {
156+
expiration: {
157+
type: "EX",
158+
value: 3600, // 1 hour
159+
},
160+
});
155161

156162
if (Math.random() < 0.1 && !isEmoji)
157163
if (Math.random() < 0.2)
@@ -215,12 +221,12 @@ export default async function (msg: Message, type: string): Promise<void> {
215221

216222
if (
217223
(handler.role === "super-admin" && !msg.fromMe) ||
218-
(handler.role === "admin" && !isUserAdmin)
224+
(handler.role === "admin" && !(isUserAdmin || msg.fromMe))
219225
) {
220226
return;
221227
}
222228

223-
log.info("Message", lid, msg.body.slice(0, 150));
229+
log.info("Message", lid, key);
224230
msg.body = newMessageBody;
225231

226232
/*
@@ -237,7 +243,7 @@ export default async function (msg: Message, type: string): Promise<void> {
237243
options?: MessageSendOptions,
238244
): Promise<Message> => {
239245
let messageBody = typeof content === "string" ? Font(content) : content;
240-
log.info("ReplyMessage", lid, content.toString().slice(0, 150));
246+
log.info("Reply", lid, key);
241247

242248
if (!msg.fromMe) {
243249
const chat = await msg.getChat();

src/components/events/reaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default async function (client: Client, react: Reaction): Promise<void> {
4949
},
5050
}),
5151
]);
52-
log.info("Reaction", senderId, `Reacted to message with ${react.reaction}`);
52+
log.info("Reaction", senderId, react.reaction);
5353
} catch (err) {
5454
Sentry.captureException(err);
5555
log.error("Failed to react back to message:", err);

src/components/events/revoke.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default async function (
4545
? MessageMedia.fromFilePath(downloadFilePath)
4646
: null;
4747

48-
log.info("RevokeMessage", lid, revoked_msg.body);
48+
log.info("RevokeMessage", lid);
4949
await Promise.all([
5050
addMessage(lid, revoked_msg.body, "revoke"),
5151
msg.reply(media || caption, undefined, {

0 commit comments

Comments
 (0)