Skip to content

Commit 21e8e41

Browse files
committed
Added mentionIds to bot reply
1 parent f209ca6 commit 21e8e41

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

src/commands/ai.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,11 @@ export default async function (msg: Message) {
4949
return;
5050
}
5151

52-
await msg.reply(text);
52+
const mentionIdRegExp: RegExp = /@([^\s]+)/g
53+
const mentions: string[] = [...text.matchAll(mentionIdRegExp)].map(matchId => {
54+
if (/^\+?\d+$/.test(matchId[1])) return (matchId[0] + "c.us")
55+
return matchId[0]
56+
});
57+
58+
await msg.reply(text, undefined, { mentions });
5359
}

src/commands/chad.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,11 @@ export default async function (msg: Message) {
6060
return;
6161
}
6262

63-
await msg.reply(text);
63+
const mentionIdRegExp: RegExp = /@([^\s]+)/g
64+
const mentions: string[] = [...text.matchAll(mentionIdRegExp)].map(matchId => {
65+
if (/^\+?\d+$/.test(matchId[1])) return (matchId[0] + "c.us")
66+
return matchId[0]
67+
});
68+
69+
await msg.reply(text, undefined, { mentions });
6470
}

src/commands/dave.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,11 @@ export default async function (msg: Message) {
6464
return;
6565
}
6666

67-
await msg.reply(text);
67+
const mentionIdRegExp: RegExp = /@([^\s]+)/g
68+
const mentions: string[] = [...text.matchAll(mentionIdRegExp)].map(matchId => {
69+
if (/^\+?\d+$/.test(matchId[1])) return (matchId[0] + "c.us")
70+
return matchId[0]
71+
});
72+
73+
await msg.reply(text, undefined, { mentions });
6874
}

src/commands/sim.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,11 @@ export default async function (msg: Message) {
5050
return;
5151
}
5252

53-
await msg.reply(text);
53+
const mentionIdRegExp: RegExp = /@([^\s]+)/g
54+
const mentions: string[] = [...text.matchAll(mentionIdRegExp)].map(matchId => {
55+
if (/^\+?\d+$/.test(matchId[1])) return (matchId[0] + "c.us")
56+
return matchId[0]
57+
});
58+
59+
await msg.reply(text, undefined, { mentions });
5460
}

0 commit comments

Comments
 (0)