import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./config-BYRrjYC5.mjs";import{t as n}from"./parse-date-BdYTmLpo.mjs";import{t as r}from"./config-not-found-B9AOp828.mjs";import{t as i}from"./cache-DCQ3KkFK.mjs";const a={path:`/message/system/:uid`,categories:[`social-media`],example:`/bilibili/message/system/2267573`,parameters:{uid:`用户 id`},features:{requireConfig:[{name:`BILIBILI_COOKIE_*`,description:"BILIBILI_COOKIE_{uid}: 用于用户关注动态系列路由，对应 uid 的 b 站用户登录后的 Cookie 值，`{uid}` 替换为 uid，如 `BILIBILI_COOKIE_2267573`，获取方式：\n    1.  打开 [https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=0&type=8](https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=0&type=8)\n    2.  打开控制台，切换到 Network 面板，刷新\n    3.  点击 dynamic_new 请求，找到 Cookie\n    4.  视频和专栏，UP 主粉丝及关注只要求 `SESSDATA` 字段，动态需复制整段 Cookie"}],requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},name:`系统通知`,maintainers:[`pilgrimlyieu`],handler:s,description:`:::warning
  用户消息需要 b 站登录后的 Cookie 值，所以只能自建，详情见部署页面的配置模块。
:::`};function o(e){return e.replaceAll(/#\{([^}]+)\}\{"([^"]+)"\}/g,`<a href="$2">$1</a>`)}async function s(a){let s=a.req.param(`uid`),c=await i.getUsernameFromUID(s),l=t.bilibili.cookies[s];if(l===void 0)throw new r(`缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值`);let u=await e(`https://message.bilibili.com/x/sys-msg/query_user_notify`,{query:{page_size:20,build:0,mobi_app:`web`},headers:{Referer:`https://message.bilibili.com/`,Cookie:l}});if(u.code!==0)throw Error(u.message??u.msg??`Error code ${u.code}`);let d=(u.data.system_notify_list||[]).map(e=>{let t=`<p><strong>${e.title}</strong></p>`,r=o(e.content);t+=`<p>${r.replaceAll(`
`,`<br>`)}</p>`,e.source.logo&&(t+=`<p><img src="${e.source.logo.replace(`http://`,`https://`)}" width="40" /></p>`),e.card_cover&&(t+=`<p><img src="${e.card_cover.replace(`http://`,`https://`)}" /></p>`);let i=e.card_link||`https://message.bilibili.com/#/system`;return{title:e.title,description:t,link:i,pubDate:n(e.time_at),guid:`bilibili-system-notify-${e.id}-${e.cursor}`}});return{title:`${c} 的 B站消息 - 系统通知`,link:`https://message.bilibili.com/#/system`,description:`${c} 的 B站消息 - 系统通知`,item:d,allowEmpty:!0}}export{a as route};