From cfda21e17a174b90bc09084408e67d965b785680 Mon Sep 17 00:00:00 2001 From: Ovler Date: Fri, 14 Jun 2024 13:41:54 +0800 Subject: [PATCH] fix: Improve B23 link resolution and logging --- src/lib/server/b23.ts | 3 ++- src/lib/server/index.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/server/b23.ts b/src/lib/server/b23.ts index 0a5c992..6f4d294 100644 --- a/src/lib/server/b23.ts +++ b/src/lib/server/b23.ts @@ -20,8 +20,9 @@ const resolveB23 = async (str: string): Promise => { const urlRegex = /https?:\/\/b23\.(tv|wtf)\/\S+/g; let match: RegExpExecArray | null; let updatedString = str; + console.info("Resolving B23 links in: ", str); - const avRegex = /\/av(\d+)/g; + const avRegex = /av(\d+)/g; if ((match = avRegex.exec(str)) !== null) { let av = match[1]; const bv = av2bv(match[1]); diff --git a/src/lib/server/index.ts b/src/lib/server/index.ts index 38028e4..8a9581a 100644 --- a/src/lib/server/index.ts +++ b/src/lib/server/index.ts @@ -52,10 +52,12 @@ const handleBiliLink = async (ctx: Context) => { text = ctx.message.reply_to_message.text + "\n" + text; } text = await resolveB23(text); - const matches = /BV[a-zA-Z0-9]+/i.exec(text); + console.info("Resolved", text); + const matches = /BV[a-zA-Z0-9]+/.exec(text); if (!matches) { return; } + console.info("Regex matches", matches[0]); const bv = new Bvid(matches[0]); console.log("Found", ctx.chat.id, ctx.message.text); let pending;