Skip to content

Commit 291f807

Browse files
authored
Insta delete (#565)
* Support instagram deletions * Support tiktok deletions
1 parent bcd0d82 commit 291f807

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/commands/tiktok.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ export default class TikTokLink implements SpecialCommand {
1313
cooldownTime = 0;
1414

1515
matches(message: Message<boolean>): boolean {
16+
return TikTokLink.matchesPattern(message.content);
17+
}
18+
19+
static matchesPattern(message: string): boolean {
1620
const pattern = /((www|m\.)?tiktok\.com)|(vm\.tiktok\.com)/i;
17-
return pattern.test(message.content);
21+
return pattern.test(message);
1822
}
1923

2024
async handleSpecialMessage(message: Message<true>) {

src/handler/messageDeleteHandler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import type { BotContext } from "#context.ts";
44

55
import * as pollService from "#service/poll.ts";
66

7+
import InstagramLink from "#commands/instagram.ts";
8+
import TikTokLink from "#commands/tiktok.ts";
9+
710
import log from "#log";
811

912
const deleteInlineRepliesFromBot = (messageRef: Message<true>, botUser: ClientUser) =>
@@ -27,7 +30,10 @@ export default async function (message: Message<true>, context: BotContext) {
2730
message.content.startsWith(context.prefix.command) ||
2831
message.content.startsWith(context.prefix.modCommand);
2932

30-
if (isNormalCommand) {
33+
const isInstagramLink = InstagramLink.matchesPattern(message.content);
34+
const isTikTokLink = TikTokLink.matchesPattern(message.content);
35+
36+
if (isNormalCommand || isInstagramLink || isTikTokLink) {
3137
await deleteInlineRepliesFromBot(message, context.client.user);
3238
}
3339
}

0 commit comments

Comments
 (0)