Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
🔖 bump version 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
CMHopeSunshine committed Nov 30, 2023
1 parent 0461114 commit d29cb92
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ _✨ 大别野 协议适配 ✨_

## 安装

`nb create`创建项目时选择`Villa`适配器
`nb create` 创建项目时选择 `Villa` 适配器

或在现有`NoneBot2`项目目录下使用脚手架安装:
或在现有 `NoneBot2` 项目目录下使用脚手架安装:

```
nb adapter install nonebot-adapter-villa
Expand All @@ -44,7 +44,7 @@ nb adapter install nonebot-adapter-villa
- `bot_id`: 机器人 id,以`bot_`开头
- `bot_secret`: 机器人密钥
- `pub_key`: 加密和验证所需的 pub_key (请使用开放平台中的复制按钮而不是手动复制)
- `test_villa_id`: Bot 未上线时填写调试别野的id,已上线可不填或填 `0`
- `test_villa_id`: Bot 未上线时填写调试别野的 id,已上线可不填或填 `0`

此外,还要根据连接方式填写额外配置:

Expand Down Expand Up @@ -82,7 +82,7 @@ VILLA_BOTS='
websocket 配置完整示例:

```dotenv
DRIVER=~httpx+~websocket
DRIVER=~httpx+~websockets
VILLA_BOTS='
[
{
Expand All @@ -99,22 +99,22 @@ VILLA_BOTS='
## 已支持消息段

- `MessageSegment.text`: 纯文本
+ 米游社自带表情也是用text来发送,以[表情名]格式,例如:MessageSegment.text("[爱心]")
+ 支持样式:
+ 米游社自带表情也是用text来发送,以[表情名]格式,例如:`MessageSegment.text("[爱心]")`
+ 支持样式,,可叠加:
+ `bold`: 加粗
+ `italic`: 斜体
+ `underline`: 下划线
+ `strikethrough`: 删除线
+ 例如:MessageSegment.text("加粗", blod=True) + MessageSegment.text("斜体", italic=True)
+ 例如:`MessageSegment.text("加粗", blod=True) + MessageSegment.text("斜体", italic=True)`
- `MessageSegment.mention_robot`: @机器人
- `MessageSegment.mention_user`: @用户
+ `user_name``villa_id` 必须给出其中之一,给 `villa_id` 时,调用 api 来获取用户名
- `MessageSegment.mention_all`: @全体成员
- `MessageSegment.room_link`: #房间跳转链接
- `MessageSegment.link`: 超链接
+ 使用link的话链接能够点击进行跳转,使用text的话不能点击
+ 字段 `show_text` 是指链接显示的文字,但若指定了该字段,Web端大别野会无法正常跳转
+ 字段 `requires_bot_access_token` 为true时,跳转链接会带上含有用户信息的token
+ 使用 link 的话链接能够点击进行跳转,使用 text 的话不能点击
+ 字段 `show_text` 是指链接显示的文字,但若指定了该字段,Web 端大别野会无法正常跳转
+ 字段 `requires_bot_access_token` 为 True 时,跳转链接会带上含有用户信息的 token
- `MessageSegment.quote`: 引用(回复)消息
+ 不能**单独**使用,要与其他消息段一起使用
- `MessageSegment.image`: URL 图片
Expand All @@ -133,7 +133,7 @@ VILLA_BOTS='
+ 不能**单独**使用,要与其他消息段一起使用
+ 无法在 web 端显示出来
- 消息组件,有两种构造方式:
+ `MessageSegment.components`传入若干个component,适配器会自动根据组件显示的文本长度来计算组件面板布局(推荐)
+ `MessageSegment.components`传入若干个 component,适配器会自动根据组件显示的文本长度来计算组件面板布局(推荐)
+ `MessageSegment.panel`:传入一个组件模板 ID 或自己构造好的自定义组件面板布局 `Panel` 对象


Expand Down Expand Up @@ -258,6 +258,7 @@ com_msg = MessageSegment.panel(panel)
# 如果有预先设置好的消息组件模板 ID,可以直接使用
template_id = 123456
com_msg = MessageSegment.panel(template_id)
# 模板通过 Bot.create_component_template 接口来创建

# 如果有多个 MessageSegment.panel 相加,则只会发送最后一个
```
Expand Down
2 changes: 1 addition & 1 deletion nonebot/adapters/villa/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ async def _loop(self, bot: Bot, ws: WebSocket):
if isinstance(payload, KickOff):
log("WARNING", f"Bot {bot.self_id} kicked off by server: {payload}")
raise DisconnectError
log("INFO", f"<y>Bot {bot.self_id} disconnected: {payload}</y>")
log("INFO", f"<y>Bot {bot.self_id} disconnected</y>")
if bot.self_id in self.bots:
self.ws.pop(bot.self_id)
self.bot_disconnect(bot)
Expand Down
2 changes: 1 addition & 1 deletion nonebot/adapters/villa/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ def _parse_components(components: List[Component]) -> Optional[Panel]:
if len(mid_total[-1]) >= 2:
mid_total.append([])
elif com_lenght <= 30:
big_total[-1].append([com])
big_total.append([com])
else:
log("warning", f"component {com.id} text is too long, ignore")
if not small_total[-1]:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot-adapter-villa"
version = "1.3.2"
version = "1.3.3"
description = "NoneBot2 米游社大别野 Bot 适配器。MiHoYo Villa Bot adapter for nonebot2."
authors = ["CMHopeSunshine <277073121@qq.com>"]
license = "MIT"
Expand Down

0 comments on commit d29cb92

Please sign in to comment.