Skip to content

Commit

Permalink
fix: Improve B23 link resolution and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovler-Young committed Jun 14, 2024
1 parent 89dde5d commit cfda21e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/server/b23.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ const resolveB23 = async (str: string): Promise<string> => {
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]);
Expand Down
4 changes: 3 additions & 1 deletion src/lib/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cfda21e

Please sign in to comment.