UNPKG

koishi-plugin-kbot

Version:
26 lines (25 loc) 720 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.b23Extract = void 0; async function b23Extract(text, http) { const reg = /b23.(tv|wtf)[\\/]+(\w+)/; const regValue = reg.exec(text); if (!regValue) return ''; const URL = `https://b23.tv/${regValue[2]}`; try { let b23URL = ''; await http.get(URL, { beforeRedirect: (options) => { if (options.hostname === 'space.bilibili.com' || options.host === 'space.bilibili.com') b23URL = options.href; }, }); return b23URL; } catch (e) { return ''; } } exports.b23Extract = b23Extract;