📝 文档迁移到 vuepress hope 主题 (#490)

* ⬆️ Bump the docs-update group with 3 updates

Bumps the docs-update group with 3 updates: [@vuepress/client](https://github.com/vuepress/core), [vue](https://github.com/vuejs/core) and [vuepress](https://github.com/vuejs/vuepress/tree/HEAD/packages/vuepress).


Updates `@vuepress/client` from 2.0.0-rc.0 to 2.0.0-rc.2
- [Release notes](https://github.com/vuepress/core/releases)
- [Changelog](https://github.com/vuepress/core/blob/main/CHANGELOG.md)
- [Commits](https://github.com/vuepress/core/compare/v2.0.0-rc.0...v2.0.0-rc.2)

Updates `vue` from 3.4.3 to 3.4.21
- [Release notes](https://github.com/vuejs/core/releases)
- [Changelog](https://github.com/vuejs/core/blob/main/CHANGELOG.md)
- [Commits](https://github.com/vuejs/core/compare/v3.4.3...v3.4.21)

Updates `vuepress` from 2.0.0-rc.0 to 2.0.0-rc.8
- [Release notes](https://github.com/vuejs/vuepress/releases)
- [Changelog](https://github.com/vuejs/vuepress/blob/master/CHANGELOG.md)
- [Commits](https://github.com/vuejs/vuepress/commits/HEAD/packages/vuepress)

---
updated-dependencies:
- dependency-name: "@vuepress/client"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: docs-update
- dependency-name: vue
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: docs-update
- dependency-name: vuepress
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: docs-update
...

Signed-off-by: dependabot[bot] <support@github.com>

* 💄 auto fix by pre-commit hooks

* 📝 使用 vuepress hope 主题

* 📝 更新文档中的过时内容

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Azide <rukuy@qq.com>
This commit is contained in:
dependabot[bot] 2024-03-18 18:37:17 +08:00 committed by GitHub
parent a6a2cc1be7
commit ed0933038e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 3220 additions and 2685 deletions

View File

@ -1,4 +1,5 @@
MD013: false
MD024: # 重复标题
siblings_only: true
MD026: false # 允许标题以符号结尾
MD033: false # 允许 html

View File

@ -40,7 +40,7 @@ _✨ 通用订阅推送插件 ✨_
<strong>🚀 快速开始</strong>
</a>
&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="https://qm.qq.com/cgi-bin/qm/qr?k=pXYMGB_e8b6so3QTqgeV6lkKDtEeYE4f&jump_from=webapi" target="__blank">
<a href="https://qm.qq.com/q/7DH4H3hbaw" target="__blank">
<strong>💬 讨论交流</strong>
</a>
@ -52,7 +52,7 @@ _✨ 通用订阅推送插件 ✨_
基于 [`NoneBot2`](https://github.com/nonebot/nonebot2) 开发(诞生于明日方舟的蹲饼活动)
<details>
<summary>本项目原名原名nonebot-hk-reporter</summary>
<summary>本项目原名原名 nonebot-hk-reporter</summary>
寓意本 Bot 要做全世界跑的最快的搬运机器人,后因名字过于暴力改名
@ -79,7 +79,7 @@ _✨ 通用订阅推送插件 ✨_
## 使用方法
**!!注意,如果要使用后台管理功能请使用 pypi 版本或者 docker 版本,如果直接 clone 源代码
**!! 注意,如果要使用后台管理功能请使用 pypi 版本或者 docker 版本,如果直接 clone 源代码
需要按下面方式进行 build**
```bash
@ -89,7 +89,7 @@ pnpm && pnpm run build
可以使用 Dockerdocker-compose作为插件安装在 nonebot 中,或者直接运行
在群里 at Bot 或者直接私聊 Bot “添加订阅”,按照提示输入需要订阅的账号,就可以愉快接收消息了。
在群里 at Bot 或者直接私聊 Bot“添加订阅”按照提示输入需要订阅的账号就可以愉快接收消息了。
参考[文档](https://nonebot-bison.vercel.app/usage/#%E4%BD%BF%E7%94%A8)

View File

@ -1,34 +1,15 @@
import { defineUserConfig, defaultTheme } from "vuepress";
import { defineUserConfig } from "vuepress";
import theme from "./theme.js";
export default defineUserConfig({
base: "/",
lang: "zh-CN",
title: "Nonebot Bison",
description: "Docs for Nonebot Bison",
theme: defaultTheme({
navbar: [
{ text: "主页", link: "/" },
{
text: "使用",
children: [
{
text: "安装",
link: "/usage/install.md",
activeMatch: "^/usage/install",
},
{
text: "入门",
link: "/usage/easy-use.md",
activeMatch: "^/usage/easy-use",
},
{
text: "详述",
link: "/usage",
activeMatch: "^/usage$",
},
],
},
{ text: "开发", link: "/dev/" },
{ text: "Github", link: "https://github.com/felinae98/nonebot-bison" },
],
}),
title: "NoneBot Bison",
description: "NoneBot Bison 文档",
theme,
// 和 PWA 一起启用
// shouldPrefetch: false,
});

33
docs/.vuepress/navbar.ts Normal file
View File

@ -0,0 +1,33 @@
import { navbar } from "vuepress-theme-hope";
export default navbar([
"/",
{
text: "指南",
icon: "book",
prefix: "/usage/",
children: [
{
text: "安装",
icon: "box-open",
link: "install",
},
{
text: "快速开始",
icon: "truck-fast",
link: "easy-use",
},
{
text: "详细介绍",
icon: "motorcycle",
link: "",
activeMatch: "^/usage/?$",
},
],
},
{
text: "开发",
icon: "flask",
link: "/dev/",
},
]);

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" class="icon" viewBox="0 0 1024 1024"><path fill="#FDD7AD" d="M512 0 335.448 88.272l-70.616 35.312-70.624 35.312-176.552 88.28v529.648L512 1024l494.344-247.176V247.176z"/><path fill="#CBB292" d="m759.176 370.76-70.624 35.304-494.344-247.168 70.624-35.312zM512 494.344V1024L17.656 776.824V247.176z"/><path fill="#7F6E5D" d="M1006.344 247.168v529.656L512 1024V494.344l176.552-88.28v70.624l141.24-70.624v-70.616z"/><path fill="#7F5B53" d="M829.792 335.448v70.624L688.56 476.68v-70.624z"/><path fill="#CBB292" d="m829.792 335.448-70.624 35.312-494.344-247.176 70.624-35.312z"/><path fill="#2C3E50" d="m682.52 550.32 157.032-78.512a17.656 17.656 0 0 1 25.552 15.792v9.32a52.96 52.96 0 0 1-29.28 47.376L678.8 622.8a17.656 17.656 0 0 1-25.552-15.792v-9.312a52.96 52.96 0 0 1 29.28-47.376z"/></svg>

After

Width:  |  Height:  |  Size: 854 B

View File

@ -0,0 +1 @@
<svg width="98" height="96" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="#24292f"/></svg>

After

Width:  |  Height:  |  Size: 963 B

View File

@ -0,0 +1 @@
<svg width="98" height="96" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 960 B

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 282 KiB

37
docs/.vuepress/sidebar.ts Normal file
View File

@ -0,0 +1,37 @@
import { sidebar } from "vuepress-theme-hope";
export default sidebar({
"/": [
"",
{
text: "指南",
icon: "laptop-code",
prefix: "usage/",
children: "structure",
},
{
text: "开发",
icon: "terminal",
prefix: "dev/",
children: "structure",
},
{
text: "相关",
icon: "person-chalkboard",
children: [
{
text: "Nonebot-Bison",
link: "https://github.com/MountainDash/nonebot-bison",
},
{
text: "Nonebot-Plugin-SAA",
link: "https://github.com/MountainDash/nonebot-plugin-send-anything-anywhere",
},
{
text: "MountainDash",
link: "https://github.com/MountainDash/",
},
],
},
],
});

View File

@ -0,0 +1,3 @@
// you can change config here
$colors: #c0392b, #d35400, #f39c12, #27ae60, #16a085, #2980b9, #8e44ad, #2c3e50,
#7f8c8d !default;

View File

@ -0,0 +1 @@
// place your custom styles here

View File

@ -0,0 +1,2 @@
// you can change colors here
$theme-color: #096dd9;

121
docs/.vuepress/theme.ts Normal file
View File

@ -0,0 +1,121 @@
import { hopeTheme } from "vuepress-theme-hope";
import navbar from "./navbar.js";
import sidebar from "./sidebar.js";
export default hopeTheme({
hostname: "https://nonebot-bison.netlify.app",
author: {
name: "MountainDash Team",
url: "https://github.com/orgs/MountainDash/teams",
},
iconAssets: "fontawesome-with-brands",
logo: "logo.svg",
repo: "MountainDash/nonebot-bison",
docsDir: "docs",
// 导航栏
navbar,
// 侧边栏
sidebar,
// 页脚
footer: "默认页脚",
displayFooter: true,
// 加密配置
encrypt: {
config: {
"/demo/encrypt.html": ["1234"],
},
},
// 多语言配置
metaLocales: {
editLink: "在 GitHub 上编辑此页",
},
// 如果想要实时查看任何改变,启用它。注: 这对更新性能有很大负面影响
// hotReload: true,
// 在这里配置主题提供的插件
plugins: {
components: {
components: ["Badge", "VPCard"],
},
// 此处开启了很多功能用于演示,你应仅保留用到的功能。
mdEnhance: {
align: true,
attrs: true,
codetabs: true,
component: true,
demo: true,
figure: true,
imgLazyload: true,
imgSize: true,
include: true,
mark: true,
stylize: [
{
matcher: "Recommended",
replacer: ({ tag }) => {
if (tag === "em")
return {
tag: "Badge",
attrs: { type: "tip" },
content: "Recommended",
};
},
},
],
sub: true,
sup: true,
tabs: true,
vPre: true,
// 在启用之前安装 chart.js
// chart: true,
// insert component easily
// 在启用之前安装 echarts
// echarts: true,
// 在启用之前安装 flowchart.ts
// flowchart: true,
// gfm requires mathjax-full to provide tex support
// gfm: true,
// 在启用之前安装 katex
// katex: true,
// 在启用之前安装 mathjax-full
// mathjax: true,
// 在启用之前安装 mermaid
// mermaid: true,
// playground: {
// presets: ["ts", "vue"],
// },
// 在启用之前安装 reveal.js
// revealJs: {
// plugins: ["highlight", "math", "search", "notes", "zoom"],
// },
// 在启用之前安装 @vue/repl
// vuePlayground: true,
// install sandpack-vue3 before enabling it
// sandpack: true,
},
},
});

View File

@ -1,35 +1,101 @@
---
home: true
icon: cubes-stacked
title: 项目主页
heroImage: logo.svg
bgImage: https://theme-hope-assets.vuejs.press/bg/6-light.svg
bgImageDark: https://theme-hope-assets.vuejs.press/bg/6-dark.svg
bgImageStyle:
background-attachment: fixed
heroText: Nonebot Bison
tagline: 通用的平台消息推送工具,励志做全泰拉骑自行车最快的信使
tagline: ✨ 通用订阅推送插件 ✨
actions:
- text: 快速部署
link: /usage/install.md
type: secondary
- text: 快速上车
link: /usage/easy-use.md
- text: 使用指南
icon: book
link: ./usage/install
type: primary
- text: 详细了解
link: /usage
type: secondary
features:
- title: 游戏发饼没看到?
details: 让Bison帮你蹲新鲜的饼热乎送上社交动态网站更新游戏开服Bison的自行车24小时风雨无阻
- title: Bison的自行车你做主
details: 自由组装自行车,想推送的平台找不到?不要紧!只需要简单的爬虫知识,就能为自行车装上新的配件派送你需要的信件!
- title: 轻松下单,送货上门!
details: 私聊、群组亦或是网页Bison提供全方位下单服务只需简单指令就能精准送达
footer: MIT Licensed
- text: 参与开发
icon: code-pull-request
link: ./dev/
highlights:
- header: 易于安装
image: /assets/image/box.svg
bgImage: https://theme-hope-assets.vuejs.press/bg/3-light.svg
bgImageDark: https://theme-hope-assets.vuejs.press/bg/3-dark.svg
highlights:
- title: 运行 <code>nb create</code> 以创建一个新的 Nonebot 项目。
- title: 在已有项目根目录下运行 <code>nb plugin install nonebot-bison</code> 以在项目中添加插件。
- title: 详细请见 <code><a href="./usage/install">使用指南</a></code>
- header: 支持平台
description: 我们支持多个平台的订阅推送
image: /assets/image/markdown.svg
bgImage: https://theme-hope-assets.vuejs.press/bg/2-light.svg
bgImageDark: https://theme-hope-assets.vuejs.press/bg/2-dark.svg
bgImageStyle:
background-repeat: repeat
background-size: initial
features:
- title: 微博
details: 国内最大的社交媒体平台
link: https://www.weibo.com
- title: 哔哩哔哩
details: 国内知名的视频弹幕网站
link: https://bilibili.com
- title: 哔哩哔哩直播
details: 哔哩哔哩的直播平台
link: https://live.bilibili.com
- title: 哔哩哔哩番剧
details: 及时更新 (?) 的动漫新番
link: https://www.bilibili.com/anime
- title: 网易云歌手
details: 网易云音乐的歌手订阅
link: https://music.163.com/#/discover/artist
- title: 网易云电台
details: 网易云音乐的电台订阅
link: https://music.163.com/#/discover/djradio
- title: 明日方舟
details: 博士,你还不能休息哦
link: https://ak.hypergryph.com/
- title: 最终幻想 14
details: 一个由玩家创造的幻想世界
link: https://adsrff.web.sdo.com/web1/
- title: 小刻食堂 (即将支持)
details: 实时获取鹰角发的动态
link: https://www.ceobecanteen.top
- title: 聚合内容
details: 简易信息聚合,即 RSS
- header: 介绍
description: 什么是 Bison
image: /assets/image/blog.svg
bgImage: https://theme-hope-assets.vuejs.press/bg/5-light.svg
bgImageDark: https://theme-hope-assets.vuejs.press/bg/5-dark.svg
highlights:
- title: 游戏发饼没看到?
icon: blog
details: 让 Bison 帮你蹲新鲜的饼热乎送上社交动态网站更新游戏开服Bison 的自行车 24 小时风雨无阻!
- title: Bison 的自行车你做主!
icon: wrench
details: 自由组装自行车,想推送的平台找不到?不要紧!只需要简单的爬虫知识,就能为自行车装上新的配件派送你需要的信件!
link: ./dev/
- title: 轻松下单,送货上门!
icon: envelope-circle-check
details: 私聊、群组亦或是网页Bison 提供全方位送货服务,只需简单指令,就能精准送达!
copyright: false
footer: 使用 <a href="https://theme-hope.vuejs.press/zh/" target="_blank">VuePress Theme Hope</a> 主题 | MIT 协议
---
<center>
<div style="background: rgba(128, 128, 128, 0.07); border-radius: 10px; background-clip: padding-box;">
<font size=4px>目前支持</font>
• 微博 • 哔哩哔哩 • 哔哩哔哩直播 • 哔哩哔哩番剧 • 网易云歌手 • 网易云电台 • 明日方舟 • FF14 • RSS •
</div>
</center>

View File

@ -1,26 +1,47 @@
---
sidebar: auto
---
# 基本开发须知
## 语言以及工具
1. 本项目使用了`python3.9`的特性进行开发,所以请确保你的 Python 版本>=3.9
1. 本项目使用了`python3.10`的特性进行开发,所以请确保你的 Python 版本>=3.10
2. 本项目使用 poetry 进行依赖管理,请确保开发之前已经进行过`poetry install`,运行时在`poetry shell`的环境中进行运行
3. 本项目使用的 node 项目管理工具是 yarn
3. 本项目使用的 node 项目管理工具是 pnpm
::: tip 参考
可以参考[安装 - 直接运行](../usage/install.md#直接运行)中的内容
:::
## 前端
本项目使用了前端,如果单独 clone 仓库本身,里面是**不包含**编译过的前端的,请使用`yarn && yarn build`进行前端的构建。
如果想要开发前端,推荐在`.env.dev`中加入`BISON_OUTER_URL="http://localhost:3000/bison/"`,然后分别运行 bot 和`yarn dev`
本项目使用了前端,如果单独 clone 仓库本身,里面是**不包含**编译过的前端的,请使用`pnpm i && pnpm build`进行前端的构建。
如果想要开发前端,推荐的步骤是:
1. 在`.env.dev`中添加`BISON_OUTER_URL`配置项
```env
BISON_OUTER_URL="http://localhost:3000/bison/"`
```
2. 运行 bot
```bash
poetry run nb run
```
3. 运行前端:
```bash
cd admin_fronted
pnpm dev
```
::: warning
请在开发前端的时候删除项目根目录中的`node_modules`,否则编译和运行的时候可能会出现奇怪的问题。
请在开发前端的时候删除项目**根目录**中的`node_modules`,否则编译和运行的时候可能会出现奇怪的问题。
:::
## 文档
文档的相关部分在`docs`目录中,可以在项目根目录执行`yarn docs:dev`预览文件更改效果。
文档的相关部分在`docs`目录中,可以在项目根目录执行`pnpm docs:dev`预览文件更改效果。
## 代码格式
@ -39,13 +60,13 @@ Nonebot 项目使用了全异步的处理方式所以你需要对异步Pyt
## 基本概念
- `nonebot_bison.post`: 可以理解为推送内容,其中包含需要发送的文字,图片,链接,平台信息等,分为:
- `nonebot_bison.post.Post`: 简单的推送内容格式,需要发送的内容由 bison 处理
- `nonebot_bison.post.CustomPost`: 基于 markdown 语法的,自由度较高的推送内容格式
- `nonebot_bison.post.Post`: 推送内容格式,传入需要发送的内容由 Theme 模块处理
- 详细的介绍可参见[生成 bison 的推送文本](#生成-bison-的推送文本)
- `nonebot_bison.types.RawPost`: 从站点/平台中爬到的单条信息
- `nonebot_bison.types.Target`: 目标账号Bilibili微博等社交媒体中的账号
- `nonebot_bison.types.Category`: 信息分类,例如视频,动态,图文,文章等
- `nonebot_bison.types.Tag`: 信息标签,例如微博中的超话或者 hashtag
- `nonebot_bison.theme.Theme`: 用于渲染`nonebot_bison.post.Post`的模块,可以理解为一个模板引擎,生成可发送的消息
## 快速上手
@ -74,8 +95,8 @@ Nonebot 项目使用了全异步的处理方式所以你需要对异步Pyt
## 实现方法
现在你需要在`nonebot_bison/platform`下新建一个 py 文件,
在里面新建一个类,继承推送类型的基类,重载一些关键的函数,然后……就完成了,不需要修改别的东西了。
现在你需要在`nonebot_bison/platform`下新建一个 `.py` 文件,
在里面新建一个类,继承推送类型的基类,重载一些关键的函数,然后……就完成了~(??)~,不需要修改别的东西了。
### 不同类型 Platform 的实现适配以及逻辑
@ -94,7 +115,7 @@ Nonebot 项目使用了全异步的处理方式所以你需要对异步Pyt
4. 调用`parse`生成正式推文
:::
参考[nonebot_bison.platform.Weibo](https://github.com/felinae98/nonebot-bison/blob/v0.5.3/src/plugins/nonebot_bison/platform/weibo.py)
参考[nonebot_bison.platform.Weibo](https://github.com/MountainDash/nonebot-bison/blob/v0.9.1/nonebot_bison/platform/weibo.py)
- `nonebot_bison.platform.platform.StatusChange`
需要实现:
@ -109,7 +130,7 @@ Nonebot 项目使用了全异步的处理方式所以你需要对异步Pyt
3. 通过则进入`parser`生成 Post
:::
参考[nonenot_bison.platform.AkVersion](https://github.com/felinae98/nonebot-bison/blob/v0.5.3/src/plugins/nonebot_bison/platform/arknights.py#L86)
参考[nonenot_bison.platform.AkVersion](https://github.com/MountainDash/nonebot-bison/blob/v0.9.1/nonebot_bison/platform/arknights.py#L122)
- `nonebot_bison.platform.platform.SimplePost`
需要实现:
@ -139,11 +160,13 @@ Nonebot 项目使用了全异步的处理方式所以你需要对异步Pyt
- `enable_tag` 平台发布内容是否带 Tag例如微博
- `platform_name` 唯一的,英文的识别标识,比如`weibo`
- `async get_target_name(Target) -> Optional[str]` 通常用于获取帐号的名称,如果平台没有帐号概念,可以直接返回平台的`name`
- `get_tags(RawPost) -> Optional[Collection[Tag]]` (可选) 从 RawPost 中提取 Tag
- `get_tags(RawPost) -> Optional[Collection[Tag]]` (可选)从 RawPost 中提取 Tag
- `get_category(RawPos) -> Optional[Category]` (可选)从 RawPost 中提取 Category
- `async parse(RawPost) -> Post` 将获取到的 RawPost 处理成 Post
- `async parse_target(str) -> Target` (可选)定制化处理传入用户输入的 Target 字符串,返回 Target一般是把用户的主页链接解析为 Target如果输入本身就是 Target则直接返回 Target
- `parse_target_promot` (可选)在要求用户输入 Target 的时候显示的提示文字
- `default_theme` (可选)默认的渲染主题,如果用户没有指定渲染主题,则优先使用这个主题进行渲染,不显式覆盖则为`basic`
- `use_batch` (可选)是否使用批量获取,如果使用批量获取,那么会调用`batch_get_sub_list`,否则调用`get_sub_list`
### 特有的方法/成员
@ -152,6 +175,8 @@ Nonebot 项目使用了全异步的处理方式所以你需要对异步Pyt
`get_sub_list(Target) -> list[RawPost]` 用于获取对应 Target 的 RawPost 列表,与上一次`get_sub_list`获取的列表比较,过滤出新的 RawPost
- 对于`nonebot_bison.platform.platform.SimplePost`
`get_sub_list` 用于获取对应 Target 的 RawPost 列表,但不会与上次获取的结果进行比较,而是直接进行发送
- `async def batch_get_sub_list(list[Target]) -> list[list[RawPost]]` (可选)输入一个`Target`的 list输出一个`RawPost`的 list 的 list用于批量获取 RawPost
- 其他类似`get_sub_list`,但是可以一次性获取多个 Target 的 RawPost
- `get_id(RawPost) -> Any` 输入一个`RawPost`,从`RawPost`中获取一个唯一的 ID这个 ID 会用来判断这条`RawPost`是不是之前收到过
- `get_date(RawPost) -> Optional[int]` 输入一个`RawPost`,如果可以从`RawPost`中提取出发文的时间,返回发文时间的 timestamp否则返回`None`
- `async get_status(Target) -> Any`
@ -167,7 +192,7 @@ Nonebot 项目使用了全异步的处理方式所以你需要对异步Pyt
你可以参照`tests/platforms/test_*.py`中的内容对单元测试进行编写。
为保证多次运行测试的一致性,可以 mock http 的响应,测试的内容应包括[获取 RawPost](https://github.com/felinae98/nonebot-bison/blob/v0.5.3/tests/platforms/test_weibo.py#L59),处理成 Post
为保证多次运行测试的一致性,可以 mock http 的响应,测试的内容应包括[获取 RawPost](https://github.com/MountainDash/nonebot-bison/blob/v0.9.1/tests/platforms/test_weibo.py#L43),处理成 Post
,测试分类以及提取 tag 等,当然最好和 rsshub 做一个交叉验证。
## 一些例子
@ -193,25 +218,25 @@ class Weibo(NewMessage):
has_target = True
async def get_target_name(self, target: Target) -> Optional[str]:
#获取Target对应的用户名
#获取 Target 对应的用户名
...
async def get_sub_list(self, target: Target) -> list[RawPost]:
#获取对应Target的RawPost列表会与上一次get_sub_list获取的列表比较过滤出新的RawPost
#获取对应 Target RawPost 列表,会与上一次 get_sub_list 获取的列表比较,过滤出新的 RawPost
...
def get_id(self, post: RawPost) -> Any:
#获取可以标识每个Rawpost的不与之前RawPost重复的id用于过滤出新的RawPost
#获取可以标识每个 Rawpost 的,不与之前 RawPost 重复的 id用于过滤出新的 RawPost
...
def get_date(self, raw_post: RawPost) -> float:
#获取RawPost的发布时间若bot过滤出的新RawPost发布时间与当前时间差超过2小时该RawPost将被忽略可以返回None
#获取 RawPost 的发布时间,若 bot 过滤出的新 RawPost 发布时间与当前时间差超过 2 小时,该 RawPost 将被忽略,可以返回 None
...
def get_tags(self, raw_post: RawPost) -> Optional[list[Tag]]:
#获取RawPost中包含的微博话题#xxx#中的内容
...
def get_category(self, raw_post: RawPost) -> Category:
#获取该RawPost在该类定义categories的具体分类(转发?视频?图文?...)
#获取该 RawPost 在该类定义 categories 的具体分类 (转发?视频?图文?...)
...
async def parse(self, raw_post: RawPost) -> Post:
#将需要bot推送的RawPost处理成正式推送的Post
#将需要 bot 推送的 RawPost 处理成正式推送的 Post
...
```
@ -219,41 +244,144 @@ class Weibo(NewMessage):
### 什么是`nonebot_bison.post`
可以认为`nonebot_bison.post`是最终要交付给 bison 推送到群内的内容,经过`parse`函数处理过后的报文应该返回属于`nonebot_bison.post`下的某个类
可以认为`nonebot_bison.post`是最终要交付给 bison 的 Theme 模块渲染,最终推送到群内的内容。
`parse`函数的工作就是将`nonebot_bison.types.RawPost`中的数据相应传入`nonebot_bison.post.Post`
经过`parse`函数处理过后的报文应该返回属于`nonebot_bison.post`下的某个类。
目前 bison 所支持的类有:
- `nonebot_bison.post.Post`
- `nonebot_bison.post.CustomPost`
### 什么是`nonebot_bison.post.Post`
Post 类存在参数`text``pics`,分别对应接收文本与图片类消息,需要注意的是`pics`接收的是一个列表 List列表中的值可以为 url 或者 bytes。
Post 会将`text``pics`分为若干条消息进行分别发送
可选参数:
使用`compress`参数将所有消息压缩为一条进行发送。
使用`extra_msg`可以携带额外的消息进行发送
使用`override_use_pic`参数可以无视全局配置中的 bison_use_pic 配置进行强制指定
可参考[Post 的用法](https://github.com/felinae98/nonebot-bison/blob/v0.5.4/src/plugins/nonebot_bison/platform/arknights.py#L227)
### 什么是`nonebot_bison.post.CustomPost`
CustomPost 类能接受的消息为[`List[MessageSegment]`](https://github.com/botuniverse/onebot-11/blob/master/message/array.md#%E6%B6%88%E6%81%AF%E6%AE%B5)
::: tip
消息段Message Segment 或 Segment
表示聊天消息的一个部分,在一些平台上,聊天消息支持图文混排,其中就会有多个消息段,分别表示每个图片和每段文字。
:::
准确来说CustomPost 只支持使用 MessageSegment 内的`text``image`类型CustomPost 会将 List 中的每个`text`类型元素理解为一个单行的 text 文本,
当然markdown 语法可以在每个`text`类型元素使用,但如果这样,在不开启`bison_use_pic`**全局配置项** 的情况下bison 会将写在 text 类型元素里的 markdown 语法按原样推送,不会解析。
对于上述情况,建议开启 CustomPost 的`override_use_pic`选项,这样 CustomPost 只会发送经过 markdown 语法渲染好的图片,而非文本消息。
CustomPost 的可选参数及作用与上文中的[Post](#什么是nonebot-bison-post-post)一致。
::: details CustomPost 例子
最通用的 Post理论上包含所有常用的数据
```python
async def parse(self, raw_post:RawPost) -> str:
#假定传入的raw_post为List[MessageSegment]
#do something...
return CustomPost(message_segments=raw_post, only_pic=True)
class Post(AbstractPost):
platform: "Platform"
"""来源平台"""
content: str
"""文本内容"""
title: str | None = None
"""标题"""
images: list[str | bytes | Path | BytesIO] | None = None
"""图片列表"""
timestamp: int | None = None
"""发布/获取时间戳"""
url: str | None = None
"""来源链接"""
avatar: str | bytes | Path | BytesIO | None = None
"""发布者头像"""
nickname: str | None = None
"""发布者昵称"""
description: str | None = None
"""发布者个性签名等"""
repost: "Post | None" = None
"""转发的 Post"""
```
额外参数 (AbstractPost)
- 使用`compress`参数将所有消息压缩为一条进行发送。
- 使用`extra_msg`可以携带额外的消息进行发送。
可参考[Post 的用法](https://github.com/MountainDash/nonebot-bison/blob/v0.9.1/nonebot_bison/platform/arknights.py#L240)
## 制作主题
### 什么是主题
主题是用于渲染`nonebot_bison.post.Post`的模块,可以理解为一个模板引擎,生成可发送的消息。
RawPost 通过`Platform.parse`函数处理成 Post然后通过`Theme.render`函数渲染成可发送的消息。
### 主题的注册
Bison 在启动时会尝试注册所有在`nonebot_bison/theme/themes`下的主题,如果你的主题在这个目录下,并指定了 `__theme_meta__`,那么它会被自动注册。
若配置项`BISON_THEME_USE_BROWSER=false`,则在注册的主题需要浏览器渲染,即`need_browser`字段为`True`时,会发出注册警告
同时,你也可以手动调用`nonebot_bison.theme.theme_manager.register`来注册主题
::: tip 另一种加载方式
理论上你自己的 Theme 可以创建在别的位置,甚至作为一个插件
这样的话想要注册这个 Theme就需要在插件里这样做
```python
from nonebot_bison.theme import theme_manager
from .path.to.your.theme import ATheme
theme_manager.register(ATheme())
```
:::
### 主题的实现
主题需要继承`nonebot_bison.theme.Theme`,并实现`render`函数
在某个 Platform 获取到 Post 之后,会根据 主题渲染规则,将 Post 传入对应的 Theme 中,然后调用`render`函数,将 Post 渲染成可发送的消息。
::: info 主题渲染规则
```python
def get_priority_themes(self) -> list[str]:
"""获取渲染所使用的 theme 名列表,按照优先级排序"""
themes_by_priority: list[str] = []
# 最先使用用户指定的 theme
if user_theme := self.get_config_theme():
themes_by_priority.append(user_theme)
# 然后使用平台默认的 theme
if self.platform.default_theme not in themes_by_priority:
themes_by_priority.append(self.platform.default_theme)
# 最后使用最基础的 theme
if "basic" not in themes_by_priority:
themes_by_priority.append("basic")
return themes_by_priority
```
:::
在获取到可渲染的主题列表后,会按照列表中的顺序依次调用`render`函数。
如果某个主题渲染失败,会继续调用下一个主题,直到渲染成功或者没有主题可用。
### 例子
想要创建一个主题,首先需要在`nonebot_bison/theme/themes`目录下创建一个新的目录,比如`mytheme`
然后在`mytheme`目录下创建一个`__init__.py`文件
接下来创建一个`build.py`文件,用于生成主题
在文件中写入:
```python
from typing import TYPE_CHECKING, Literal
from nonebot_bison.theme import Theme
if TYPE_CHECKING:
from nonebot_bison.post import Post
class MyTheme(Theme):
name: Literal["mytheme"] = "mytheme"
# 可选,该主题渲染是否需要浏览器
# need_browser: bool = ...
async def render(self, post: "Post") -> list[MessageSegmentFactory]:
...
```
`render`函数中,将传入的 post 中的数据用你所希望的方式渲染成 MessageSegmentFactory就完成了一个主题的制作
然后在`__init__.py`中注册这个主题:
```python
from .build import MyTheme
__theme_meta__ = MyTheme()
```
这样就完成了一个主题的创建Bison 会在启动时自动加载这个主题。

View File

@ -1,43 +1,48 @@
---
sidebar: auto
prev: /usage/install
next: /usage/easy-use
---
# 全方位了解 Bison 的自行车
本节将详细列出 Bison 的使用方法,包括如何配置 Bison如何使用 Bison 的后台管理网页,如何使用 Bison 的 API 等等
本节将详细列出 Bison 的使用方法,包括但不限于
- 如何配置 Bison
- 如何使用 Bison 的后台管理网页
- 如何使用 Bison 的 API
如果你想要快速上手 Bison可以前往[简单使用](/usage/easy-use.md)
## 配置
::: tip INFO
- 如果要在在 nonebot 中配置需要的**Bison 配置项**,请参考[NoneBot 配置方式](https://v2.nonebot.dev/docs/appendices/config#dotenv-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6),在`.env`/`.env.*`文件中写入希望配置的 Bison 配置项
- 请注意,在`.env`/`.env.*`中添加的配置项 **不** 需要声明变量类型
:::
- 想要在 nonebot 中配置需要的**Bison 配置项**,请参考[NoneBot 配置方式](https://v2.nonebot.dev/docs/appendices/config#dotenv-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6),在`.env`/`.env.*`文件中写入希望配置的 Bison 配置项
- 请注意,在`.env`/`.env.*`中添加的配置项 ==不需要== 声明变量类型
- `BISON_TO_ME`: 是否需要@Bot 或使用 Bot 的 Nickname 来触发 Bison默认为`True`
- `BISON_CONFIG_PATH`: 插件存放配置文件的位置,如果不设定默认为项目目录下的`data`目录
- `BISON_USE_PIC`: 将文字渲染成图片后进行发送,多用于规避风控
:::
- `BISON_TO_ME`: 是否需要 @Bot 或使用 Bot 的 Nickname 来触发 Bison 的命令,默认为`True`
- `BISON_CONFIG_PATH`<Badge text="弃用" type="warning" vertical="top"/>: 插件存放配置文件的位置,如果不设定默认为项目目录下的`data`目录,现用于从低版本迁移
- `BISON_USE_PIC`: 将几乎所有文字渲染成图片后进行发送,多用于规避风控
- `BISON_BROWSER`: 本插件使用 Chrome 来渲染图片
- 如果不进行配置,那么会在启动时候自动进行安装,在官方的 docker 镜像中已经安装了浏览器
- 使用本地安装的 Chrome设置为`local:<chrome path>`,例如`local:/usr/bin/google-chrome-stable`
- 使用 cdp 连接相关服务,设置为`wsc://xxxxxxxxx`
- 使用 browserless 提供的 Chrome 管理服务,设置为`ws://xxxxxxxx`,值为 Chrome Endpoint
::: warning
截止发布时,本项目尚不能完全与 browserless 兼容,目前建议使用镜像内自带的浏览器,即
不要配置这个变量
截止发布时,本项目尚不能完全与 browserless 兼容,目前建议使用镜像内自带的浏览器
即 **不要配置这个变量**
:::
- `BISON_SKIP_BROWSER_CHECK`: 是否在启动时自动下载浏览器,如果选择`False`会在用到浏览器时自动下载,
默认`True`
- `BISON_OUTER_URL`: 从外部访问服务器的地址,不设置或为空时默认值为 `http://localhost:<Bot运行在的端口>/bison/`
::: warning
请注意,该网址**并不能直接访问**Bison 的后台管理网页,正确的访问方法请参见[私聊机器人获取后台地址](#私聊机器人获取后台地址)
请注意,该网址**并不能直接访问** Bison 的后台管理网页,正确的访问方法请参见[私聊机器人获取后台地址](#私聊机器人获取后台地址)
:::
::: tip 配置建议
请选择你的部署情况:
<div class="outer_url_help">
<div class="outer-url-help">
<input type="checkbox" id="docker" v-model="docker"/>
<label for="docker">使用容器部署</label>
<input type="checkbox" id="server" v-model="server"/>
@ -46,7 +51,11 @@ next: /usage/easy-use
<label for="reverse-proxy">启用反代</label>
</div>
下面是配置建议:
<div class="outer_url_help" v-html="outerUrlHelp"></div>
```plaintext:no-v-pre :no-line-numbers
{{ outerUrlHelp }}
```
:::
- `BISON_FILTER_LOG`: 是否过滤来自`nonebot`的 warning 级以下的 log如果你的 bot 只运行了这个插件可以考虑
@ -55,34 +64,39 @@ next: /usage/easy-use
- `BISON_RESEND_TIMES`: 最大重发次数,默认 0
- `BISON_USE_PIC_MERGE`: 是否启用多图片时合并转发(仅限群)
- `0`: 不启用(默认)
- `0`: 不启用 (默认)
- `1`: 首条消息单独发送,剩余图片合并转发
- `2`: 所有消息全部合并转发
::: details BISON_USE_PIC_MERGE 配置项示例
- 当`BISON_USE_PIC_MERGE=1`:
- 当`BISON_USE_PIC_MERGE=1`
![simple1](/images/forward-msg-simple1.png)
- 当`BISON_USE_PIC_MERGE=2`:
- 当`BISON_USE_PIC_MERGE=2`
![simple1](/images/forward-msg-simple2.png)
:::
::: warning
启用此功能时,可能会因为待推送图片过大/过多而导致文字消息与合并转发图片消息推送间隔过大(选择模式`1`时),请谨慎考虑开启。或者选择模式`2`,使图文消息一同合并转发(可能会使消息推送延迟过长)
启用此功能时,可能会因为待推送图片过大/过多而导致文字消息与合并转发图片消息推送间隔过大 (选择模式`1`时),请谨慎考虑开启。或者选择模式`2`,使图文消息一同合并转发 (可能会使消息推送延迟过长)
:::
- `BISON_PROXY`: 使用的代理连接,形如`http://<ip>:<port>`(可选)
- `BISON_UA`: 使用的 User-Agent默认为 Chrome
- `BISON_SHOW_NETWORK_WARNING`: 是否在日志中输出网络异常,默认为`True`
- `BISON_THEME_USE_BROWSER`: 是否使用浏览器渲染主题,某些主题可能需要浏览器渲染(htmlrender),默认为`False`
- `BISON_THEME_USE_BROWSER`: 是否使用浏览器渲染主题,某些主题可能需要浏览器渲染 (htmlrender),默认为`False`
- `BISON_PLATFORM_THEME`: 为[平台](#平台)指定渲染用[主题](#主题),用于渲染推送消息,默认为`{}`
::: details BISON_PLATFORM_THEME 配置项示例
配置项使用`<platform>:<theme>`的形式来为某个平台指定其渲染主题,例如`"weibo":"basic"``"bilibili":"ht2i"`
最外层使用`{}`包裹,多个配置项之间使用逗号`,`分隔。
需要注意,`<platform>`所用内容是平台的**英文名**`<theme>`所用内容是主题的**英文名**。并且不要忘记使用双引号`""`包裹内容。
配置项使用`<platform>:<theme>`的形式来为某个平台指定其渲染主题,例如
例子:
- `"weibo":"basic"`
- `"bilibili":"ht2i"`
最外层使用`{}`包裹,多个配置项之间使用逗号`,`分隔。
需要注意,`<platform>`所用内容是平台的**代码英文名**`<theme>`所用内容是主题的**代码英文名**。
并且不要忘记使用双引号`""`包裹内容。
例子:
```env
BISON_PLATFORM_THEME={"weibo":"basic","bilibili":"ht2i"}
@ -95,56 +109,58 @@ next: /usage/easy-use
## 使用
::: warning
本节假设`COMMAND_START`置中包含`''`
本节假设`COMMAND_START`置中包含`''`
- 如果出现 bot 不响应的问题,请先排查这个设置
- 尝试在命令前添加设置的命令前缀,如`COMMAND_START=['/']`,则尝试使用`/添加订阅`
:::
:::
### 命令
#### 在本群中进行配置
所有命令都需要@bot 触发
所有命令都需要 @bot 触发
- 添加订阅(仅管理员和群主和 SUPERUSER`添加订阅`
::: details 关于中止添加订阅
对于[**v0.5.1**](https://github.com/felinae98/nonebot-bison/releases/tag/v0.5.1)及以上的版本中,已经为`添加订阅`命令添加了中止添加功能。
`添加订阅`命令的~~几乎~~各个阶段,都可以向 Bot 发送`取消`消息来中止订阅过程(需要发起者本人发送)
:::
- 查询订阅:`查询订阅`
- 删除订阅(仅管理员和群主和 SUPERUSER`删除订阅`
::: details 关于中止删除订阅
对于[**v0.5.3**](https://github.com/felinae98/nonebot-bison/releases/tag/v0.5.3)及以上的版本中,已经为`删除订阅`命令添加了中止删除功能。
`删除订阅`命令的~~几乎~~各个阶段,都可以向 Bot 发送`取消`消息来中止订阅过程(需要发起者本人发送)
:::
::: details 关于中止命令
对于[**v0.5.3**](https://github.com/felinae98/nonebot-bison/releases/tag/v0.5.3)及以上的版本中,已经为`添加订阅/删除订阅`命令添加了中止删除功能。
在命令的~~几乎~~各个阶段,都可以向 Bot 发送`取消`消息来中止流程 (需要发起者本人发送)
:::
#### 私聊机器人获取后台地址
要管理订阅,请输入`后台管理`命令,然后点击回复中的链接。你的管理权限取决于你的身份:
要管理订阅,请和 bot **私聊**输入`后台管理`命令,然后访问回复中的链接。你的管理权限取决于你的身份:
- 如果你是 superuser你可以管理所有群的订阅
- 如果你是某些群的管理员,你可以管理这些群的订阅;
- 如果你不是任何群的管理员bot 会提示你无法执行此操作。
::: tip
可以和 bot 通过临时聊天触发
:::
::: warning
::: warning 注意隐私
bot 返回的链接是网页的唯一身份凭证,不要泄露给他人。
链接有时效性,过期后需重新向 bot 索取新链接。
链接具有有时效性,过期后需重新向 bot 索取新链接。
:::
#### 私聊机器人进行配置(需要 SUPERUER 权限)
请私聊 bot`群管理`
请私聊 bot `群管理`
::: details 关于中止订阅
与普通的[`添加订阅`/`删除订阅`](#在本群中进行配置)命令一样,在`群管理`命令中使用的`添加订阅`/`删除订阅`命令也可以使用`取消`来中止订阅过
与普通的[`添加订阅`/`删除订阅`](#在本群中进行配置)命令一样,在`群管理`命令中使用的`添加订阅`/`删除订阅`命令也可以使用`取消`来中止
:::
### 命令行命令(CLI)
### 命令行命令 (CLI)
```CLI
Bison 在 `nb-cli` 中注册了一些命令,用于导出和导入订阅信息。
```shell
nb bison --help
```
```plaintext:no-line-numbers
Nonebot Bison CLI, 目前用于实现Bison订阅的导入导出功能
用法:
@ -153,14 +169,14 @@ Nonebot Bison CLI, 目前用于实现Bison订阅的导入导出功能
Command(命令):
export:
导出Nonebot Bison Exchangable Subcribes File
导出 Nonebot Bison Exchangable Subcribes File
Options(选项):
-p, --path TEXT 导出路径, 如果不指定,则默认为工作目录
--format [json|yaml|yml] 指定导出格式[json, yaml],默认为 json
--help 显示帮助
import:
从Nonebot Biosn Exchangable Subscribes File导入订阅
Nonebot Biosn Exchangable Subscribes File 导入订阅
Options(选项):
-p, --path TEXT 导入文件名 [必须]
--format [json|yaml|yml] 指定导入格式[json, yaml],默认为 json
@ -171,31 +187,31 @@ Command(命令):
Bison 支持的平台如下:
- arknights: 明日方舟游戏信息
- bilibili: B站
- bilibili-live: Bilibili直播
- bilibili-bangumi: Bilibili剧集
- ff14: 最终幻想XIV官方公告
- ncm-artist: 网易云-歌手
- ncm-radio: 网易云-电台
- rss: RSS
- weibo: 新浪微博
- `arknights`: 明日方舟游戏信息
- `bilibili`: B
- `bilibili-live`: Bilibili 直播
- `bilibili-bangumi`: Bilibili 剧集
- `ff14`: 最终幻想 XIV 官方公告
- `ncm-artist`: 网易云 - 歌手
- `ncm-radio`: 网易云 - 电台
- `rss`: RSS
- `weibo`: 新浪微博
:::tip
配置 `BISON_PLATFORM_THEME` 时,所用的 `<platform>``:`的值
配置 `BISON_PLATFORM_THEME` 时,所用的 `<platform>``:`的值
:::
### 主题
Bison 支持的主题如下:
- basic: 基础主题,是每个平台都会支持的主题
- ht2i: 使用 `nonebot-plugin-htmlrender` 插件,将文本渲染成图片的主题
- brief: 简报主题,仅发送标题、链接、图片
- arknights: 明日方舟专用主题,渲染为明日方舟公告风格
- `basic`: 基础主题,是每个平台都会支持的主题
- `ht2i`: 使用 `nonebot-plugin-htmlrender` 插件,将文本渲染成图片
- `brief`: 简报主题,仅发送标题、链接、图片
- `arknights`: 明日方舟专用主题,渲染为明日方舟公告风格
:::tip
配置 `BISON_PLATFORM_THEME` 时,所用的 `<theme>``:`的值
配置 `BISON_PLATFORM_THEME` 时,所用的 `<theme>``:`的值
:::
### 所支持平台的 uid
@ -211,30 +227,31 @@ Bison 支持的主题如下:
#### RSS
RSS 链接即为 uid
整个 RSS 链接即为 uid
#### 网易云音乐-歌手
#### 网易云音乐 - 歌手
在网易云网页上歌手的链接一般为`https://music.163.com/#/artist?id=32540734``id=`
后面的数字即为 uid
在网易云网页上歌手的链接一般为`https://music.163.com/#/artist?id=32540734``id=` 后面的数字即为 uid
#### 网易云音乐-电台
#### 网易云音乐 - 电台
在网易云网页上电台的链接一般为`https://music.163.com/#/djradio?id=793745436``id=`
后面的数字即为 uid
在网易云网页上电台的链接一般为`https://music.163.com/#/djradio?id=793745436``id=` 后面的数字即为 uid
### 平台订阅标签Tag
Tag 是社交平台中一种常见的功能,它用井号(#)作为前缀,标记关键词,方便用户搜索相关内容。
例如:`#明日方舟# #每日打卡#(微博、哔哩哔哩) #baracamp推特`
Tag 是社交平台中一种常见的功能,它用井号 (#) 作为前缀,标记关键词,方便用户搜索相关内容。
例如:
- `#明日方舟#` `#每日打卡#`(微博、哔哩哔哩)
- `#baracamp`(推特)
在 Bison 中,用户可以在添加平台账号订阅时(如果该平台支持 hashtag 功能),
选择需要订阅或屏蔽的 Tag。
订阅 Tag 的方法是直接向 Bison 发送一系列 Tag用空格分隔。
**订阅** Tag 的方法是直接向 Bison 发送一系列 Tag用空格分隔。
例如:`A1行动预备组 罗德厨房——回甘`
屏蔽 Tag 的方法是在 Tag 前加上前缀~,也用空格分隔。
**屏蔽** Tag 的方法是在 Tag 前加上前缀~,也用空格分隔。
例如:`~123罗德岛 ~莱茵生命漫画`
订阅和屏蔽的 Tag 可以同时使用,按照上述方法发送即可。
@ -242,14 +259,20 @@ Tag 是社交平台中一种常见的功能,它用井号(#)作为前缀,标
#### Tag 的推送规则
Bison 在处理每条推送时,会按照以下规则检查推送中的 Tag
Bison 在处理每条推送时,会按照以下规则顺序检查推送中的 Tag
- 如果推送中含有任何已记录的**需屏蔽 Tag**Bison 会直接**丢弃**该推送,不进行后续检查。
- 如果推送中含有任何已记录的**需订阅 Tag**Bison 会将该推送发送到群中,不管是否有其他 Tag。
- 如果**没有记录**任何需订阅 TagBison 会将所有通过第一条规则检查的推送发送到群中。
- 如果记录了至少一个需订阅 TagBison 会**丢弃所有**不含任何需订阅 Tag 的推送,即使通过了第一条规则检查。
对于每条推送:
<script setup>
1. 检查 **需屏蔽 Tag** 列表
- 如果推送中的 Tag 存在于 **需屏蔽 Tag** 列表中,则立刻**丢弃**该推送,检查结束
- 如果推送中的 Tag 不存在于 **需屏蔽 Tag** 列表中,则**继续**第 2 条规则的检查
2. **需订阅 Tag** 列表不为空
- 如果推送中的任何一个 Tag 存在于 **需订阅 Tag** 列表中,则**发送**该推送到群中,检查结束
- 如果推送中的每一个 Tag 都不存在于 **需订阅 Tag** 列表中,则**丢弃**该推送,检查结束
3. **需订阅 Tag** 列表为空
- **发送**该推送到群中,检查结束
<script setup lang="ts">
import { ref, computed } from 'vue';
const docker = ref(false);
@ -257,47 +280,47 @@ const server = ref(false);
const reverseProxy = ref(false);
const outerUrlHelp = computed(() => {
let helpText = '';
let helpText: string[] = [];
if ((docker.value || server.value) && !reverseProxy.value)
helpText += '将Bot配置中的 <code>HOST</code> 部分设置为 <code>0.0.0.0</code><br>';
if ((docker.value || server.value) && !reverseProxy.value)
helpText.push('HOST=0.0.0.0');
if (docker.value && !server.value && !reverseProxy.value)
helpText += '将 <code>BISON_OUTER_URL</code> 设置为 <code>http://localhost:[Docker映射到主机的端口]/bison/</code><br>';
helpText.push('BISON_OUTER_URL=http://localhost:[Docker 映射到主机的端口]/bison/');
if (server.value && !reverseProxy.value){
if (docker.value)
helpText += '将 <code>BISON_OUTER_URL</code> 设置为 <code>http://[你的服务器ip]:[Docker映射到主机的端口]/bison/</code><br>';
helpText.push('BISON_OUTER_URL=http://[你的服务器 ip]:[Docker 映射到主机的端口]/bison/');
else
helpText += '将 <code>BISON_OUTER_URL</code> 设置为 <code>http://[你的服务器ip]:[Bot运行的端口]/bison/</code><br>';
helpText.push('BISON_OUTER_URL=http://[你的服务器 ip]:[Bot 运行的端口]/bison/');
}
if (reverseProxy.value){
if (server.value){
helpText += '将 <code>BISON_OUTER_URL</code> 设置为 <code>http://[你的服务器ip]:[反代端口]/bison/</code><br>';
helpText.push('BISON_OUTER_URL=http://[你的服务器 ip]:[反代端口]/bison/');
if (docker.value)
helpText += '请注意反代端口应该指向Docker映射到主机的端口<br>';
helpText.push('# 请注意反代端口应该指向 Docker 映射到主机的端口<br>');
else
helpText += '请注意反代端口应该指向Bot运行的端口<br>';
helpText.push('# 请注意反代端口应该指向 Bot 运行的端口');
}
else
helpText += '谁没事在自己电脑上起反代啊(<br>';
helpText.push('谁没事在自己电脑上起反代啊(');
}
if (!docker.value && !server.value && !reverseProxy.value)
helpText += '你无需设置此项<br>';
return helpText;
if (!docker.value && !server.value && !reverseProxy.value)
helpText.push('你无需设置此项');
return helpText.join('\n');
});
</script>
<style>
.outer_url_help {
.outer-url-help {
margin-top: 10px;
margin-bottom: 10px;
}
.outer_url_help label {
.outer-url-help label {
margin-right: 15px;
}
</style>

View File

@ -1,7 +1,6 @@
---
sidebar: auto
prev: /usage/install
next: /usage
next: /usage/
---
# :package: Bison 的第一个包裹
@ -22,25 +21,25 @@ next: /usage
在本节中,我们假设`COMMAND_START`设置中包含`'/'`,也就是说,我们的命令前缀是`/`
例如:`COMMAND_START=['', '/']`
2. `BISON_TO_ME`
是否需要@Bot 或使用 Bot 的 Nickname 来触发 Bison默认为`True`
是否需要 @Bot 或使用 Bot 的 Nickname 来触发 Bison默认为`True`
例如:
- `BISON_TO_ME=True`
`@Bot /help`
- `BISON_TO_ME=False`
`/help`
3. `BISON_USE_PIC`
将文字渲染成图片后进行发送,多用于规避风控, 默认为`False`
将文字渲染成图片后进行发送,多用于规避风控默认为`False`
4. `BISON_USE_PIC_MERGE`: 是否启用多图片时合并转发(仅限群)
- `0`: 不启用(默认)
- `0`: 不启用 (默认)
- `1`: 首条消息单独发送,剩余图片合并转发
- `2`: 所有消息全部合并转发
::: details BISON_USE_PIC_MERGE 配置项示例
- 当`BISON_USE_PIC_MERGE=1`:
- 当`BISON_USE_PIC_MERGE=1`
![simple1](/images/forward-msg-simple1.png)
- 当`BISON_USE_PIC_MERGE=2`:
- 当`BISON_USE_PIC_MERGE=2`
![simple1](/images/forward-msg-simple2.png)
:::
@ -108,10 +107,10 @@ Bison 会要求你给出你想要订阅的目标,这个目标可以是一个 u
![choose category](/images/choose-category.png)
这里选择订阅明日方舟微博的`视频 图文 文字`类别当该账号在微博发送了视频、图文、文字时Bison 会将其派送到你的群聊中
## :bookmark: 选择需要特定订阅/屏蔽的话题(tag)
## :bookmark: 选择需要特定订阅/屏蔽的话题 (tag)
::: tip 什么是话题(tag)
Tag 是社交平台中一种常见的功能,它用井号(#)作为前缀,标记关键词,方便用户搜索相关内容。
::: tip 什么是话题 (tag)
Tag 是社交平台中一种常见的功能,它用井号 (#) 作为前缀,标记关键词,方便用户搜索相关内容。
例如:`#明日方舟# #每日打卡#(微博、哔哩哔哩) #baracamp推特`
具体的过滤规则参见[Tag 的推送规则](/usage/#tag-的推送规则)
@ -136,7 +135,7 @@ Tag 是社交平台中一种常见的功能,它用井号(#)作为前缀,标
## :globe_with_meridians: 使用网页管理订阅
Bison 提供了一个网页管理订阅的功能,你可以在网页上查看、添加、删除订阅
Bison 提供了一个网页管理订阅的功能,即 WebUI你可以在网页上查看、添加、删除订阅
如果需要使用,请 **私聊** Bison 发送`后台管理`命令Bison 会给你发送一个网页链接,在浏览器打开即可进入网页管理订阅的界面
::: tip 该命令无效?
`后台管理`命令仅对`SUPERUSERS`的私聊有效
@ -144,9 +143,9 @@ Bison 提供了一个网页管理订阅的功能,你可以在网页上查看
::: tip Bison 给出的链接无效?
Bison 所给的链接中的 ip 和 port 是`BISON_OUTER_URL`配置决定的,也就是说 Bison 本身不能获取服务器的 ip 与自身的 port所以 Bison 给出的链接可能是无效的。你可以在`BISON_OUTER_URL`中设置你的服务器 ip 与 port或者直接修改 Bison 给出的链接为正确的`http://<ip>:<port>/bison/...`来进入网页管理订阅的界面。
参见[详细介绍-配置](/usage/#配置)的`BISON_OUTER_URL`部分
参见[详细介绍 - 配置](/usage/#配置)的`BISON_OUTER_URL`部分
:::
::: tip 认证失败?
:bug:
在浏览器输入网址进入网页时,第一次进入可能会出现 unauthorized请再输入网址重新进入一次
在浏览器输入网址进入网页时,第一次进入可能会出现 unauthorized请再输入网址重新进入一次,而**不能**简单的刷新页面
:::

View File

@ -1,17 +1,16 @@
---
sidebar: auto
prev: /usage
prev: /usage/
next: /usage/easy-use
---
# 让拜松骑上自行车
本节将教你部署 nonebot-bison 项目
想知道如何开始使用请看[简单使用](/usage/easy-use.md)或者[详细配置](/usage)
本节将讲解如何部署 nonebot-bison 项目
使用部分介绍请看 [简单使用](/usage/easy-use.md) 或者 [详细配置](/usage)
## 如何选择?
- 没有其他需要,只想使用 Nonebot-Bison在 Bison 的基础上再加入其他插件?
- 没有其他需要,只想使用 Nonebot-Bison以 Bison 的基础扩展其他插件?
试试[**作为 Bot 使用**](#作为-bot-使用)
- 已有项目,想要增加 Nonebot-Bison
试试[**作为插件使用**](#作为插件使用)
@ -29,10 +28,10 @@ next: /usage/easy-use
### 使用 nb-cli 安装 <Badge type="tip" text="推荐" vertical="top" />
1. 安装`nb-cli`
1. 安装[`nb-cli`](https://cli.nonebot.dev/docs/guide/installation)
```bash
pip install nb-cli
pipx install nb-cli
```
2. 使用`nb-cli`执行在**项目根目录**执行
@ -41,14 +40,30 @@ next: /usage/easy-use
nb plugin install nonebot-bison
```
3. 在项目中添加依赖
```bash
poetry add nonebot-bison
```
### 手动安装
1. 安装 pip 包`nonebot-bison`
::: code-tabs
@tab poetry
```bash
poetry add nonebot-bison
```
@tab pip
```bash
pip install nonebot-bison
```
:::
2. 在`pyproject.toml`中导入插件`nonebot_bison`
编辑项目根目录下的`pyproject.toml`文件,添加如下内容:
@ -79,36 +94,34 @@ next: /usage/easy-use
2. 在目录中下载[docker-compose.yml](https://raw.githubusercontent.com/felinae98/nonebot-bison/main/docker-compose.yml)
将其中的`<your QQ>`改成自己的 QQ 号
:::: code-group
::: code-group-item linux
::: code-tabs#shell
@tab linux
```bash
wget https://raw.githubusercontent.com/felinae98/nonebot-bison/main/docker-compose.yml
```
:::
::: code-group-item windows
@tab windows
```powershell
Invoke-WebRequest -Uri https://raw.githubusercontent.com/felinae98/nonebot-bison/main/docker-compose.yml -OutFile docker-compose.yml
```
:::
::::
部分片断:
```yml
...
HOST: 0.0.0.0 # 0.0.0.0代表监听所有地址
# SUPERUSERS: '[<your QQ>]' #取消该行注释,并将<your QQ>改为自己的QQ号
HOST: 0.0.0.0 # 0.0.0.0 代表监听所有地址
# SUPERUSERS: '[<your QQ>]' #取消该行注释,并将<your QQ>改为自己的 QQ
BISON_CONFIG_PATH: /data
# BISON_OUTER_URL: 'http://<your server ip>:8080/bison'
#取消上行注释,并将<your server ip>改为你的服务器ipbison不会自动获取ip
#取消上行注释,并将<your server ip>改为你的服务器 ipbison 不会自动获取 ip
BISON_FILTER_LOG: 'true'
BISON_USE_PIC: 'false' # 如果需要将文字转为图片发送请改为true
BISON_USE_PIC: 'false' # 如果需要将文字转为图片发送请改为 true
ports:
- 8080:8080 # 容器映射的端口如果需要修改请同时修改上面的BISON_OUTER_URL
- 8080:8080 # 容器映射的端口,如果需要修改请同时修改上面的 BISON_OUTER_URL
...
```
@ -116,7 +129,9 @@ next: /usage/easy-use
想要指定更多配置请参考[详细配置](/usage#配置)
:::
3. 启动 Bot这里请八仙过海
3. 启动项目
- 在目录中运行`docker-compose up -d`启动 Nonebot-Bison
- 启动 Bot 端(这里请八仙过海)
### docker 部署
@ -141,10 +156,15 @@ docker run -d --name nonebot-bison \
### 直接运行 <Badge type="warning" text="不推荐" vertical="top" />
可以参考[nonebot 的运行方法](https://docs.nonebot.dev/guide/getting-started.html)
相当于进行了源码部署,或者说是开发模式的部署。
可以参考[nonebot 的运行方法](https://nonebot.dev/docs/quick-start)
::: danger
直接克隆源代码需要自行编译前端,否则会出现无法使用管理后台等情况。
Bison 的 WebUI 是需要编译后才能使用的,直接克隆源代码需要自行编译前端,否则会出现无法使用管理后台等情况。
:::
#### 本体安装
::: danger
本项目中使用了 Python 3.10 的语法,如果出现问题,请检查 Python 版本
:::
@ -158,24 +178,62 @@ docker run -d --name nonebot-bison \
poetry install
```
3. 安装 yarn配置 yarn 源
#### WebUI 安装
- 安装[`Node.js`](https://nodejs.org/en/download)
- 安装`yarn`
1. 安装包管理器
Bison 仓库中使用了`pnpm`作为包管理器,如果没有安装请先安装`pnpm`
当然如果你因为一些原因不想使用`pnpm`,可以使用`yarn`或者`npm`进行安装
```bash
npm install -g yarn
```
- pnpm
参见 [pnpm 安装](https://pnpm.io/zh/installation)
- yarn
- 安装[Node.js](https://nodejs.org/en/download)
- 安装 yarn: `npm install -g yarn`
4. 在`admin-fronted`目录中运行`yarn && yarn build`编译前端
2. 在`admin-fronted`目录中编译前端
```bash
cd admin-frontend
```
::: code-tabs
@tab pnpm
```shell
pnpm install
pnpm build
```
@tab yarn
```shell
yarn && yarn build
```
5. 编辑`.env.prod`配置各种环境变量,见[Nonebot2 配置](https://v2.nonebot.dev/docs/appendices/config)
:::tip 找不到 .env.prod
@tab npm
```shell
npm i
npm build
```
:::
构建完毕后dist 目录中生成的前端文件会自动移入`nonebot_bison/admin_page/dist`目录中,请前往检查
#### 运行
::: info 注意
构建完前端后,请回到项目根目录
:::
1. 编辑`.env.prod`配置各种环境变量,见[Nonebot2 配置](https://v2.nonebot.dev/docs/appendices/config)
:::tip 找不到 .env.prod
`.env.prod`文件在项目根目录下,请确认当前目录为项目根目录
:::
6. 运行`poetry run python bot.py`启动 Bot
2. 启动 Bot
```bash
poetry run nb run
```

View File

@ -1,19 +1,19 @@
{
"name": "nonebot-bison-docs",
"version": "1.0.0",
"description": "Docs for nonebot-bison",
"main": "index.js",
"repository": "git@github.com:felinae98/nonebot-bison-docs.git",
"author": "felinae98 <731499577@qq.com>",
"description": "Docs for Nonebot Bison",
"license": "MIT",
"private": false,
"devDependencies": {
"@vuepress/client": "2.0.0-rc.0",
"vue": "^3.4.3",
"vuepress": "2.0.0-rc.0"
},
"type": "module",
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
"docs:build": "vuepress-vite build docs",
"docs:clean-dev": "vuepress-vite dev docs --clean-cache",
"docs:dev": "vuepress-vite dev docs",
"docs:update-package": "pnpm dlx vp-update"
},
"devDependencies": {
"@vuepress/bundler-vite": "2.0.0-rc.8",
"vue": "^3.4.16",
"vuepress": "2.0.0-rc.8",
"vuepress-theme-hope": "2.0.0-rc.31"
}
}

2777
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

1652
yarn.lock

File diff suppressed because it is too large Load Diff