Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/commands/tiktok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ export default class TikTokLink implements SpecialCommand {
cooldownTime = 0;

matches(message: Message<boolean>): boolean {
return TikTokLink.matchesPattern(message.content);
}

static matchesPattern(message: string): boolean {
const pattern = /((www|m\.)?tiktok\.com)|(vm\.tiktok\.com)/i;
return pattern.test(message.content);
return pattern.test(message);
}

async handleSpecialMessage(message: Message<true>) {
Expand Down
8 changes: 7 additions & 1 deletion src/handler/messageDeleteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import type { BotContext } from "#context.ts";

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

import InstagramLink from "#commands/instagram.ts";
import TikTokLink from "#commands/tiktok.ts";

import log from "#log";

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

if (isNormalCommand) {
const isInstagramLink = InstagramLink.matchesPattern(message.content);
const isTikTokLink = TikTokLink.matchesPattern(message.content);

if (isNormalCommand || isInstagramLink || isTikTokLink) {
await deleteInlineRepliesFromBot(message, context.client.user);
}
}
Expand Down