Skip to content

Commit

Permalink
配置补全
Browse files Browse the repository at this point in the history
  • Loading branch information
zangxx66 committed Apr 15, 2023
1 parent d480b37 commit 108e7fb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ python -m pip install nonebot-plugin-blive-danmaku
|名称|类型|默认值|描述|
|-----|-----|-----|-----|
|danmaku_group_notice|bool|False|全局群开播提醒|
|danmaku_host|str||外部访问地址,若配置了公网访问地址请填写此项,以便bot能够发送正确的面板地址,例如:`“http://www.your_domain.com”``“http://192.168.0.2"`|

## 指令

Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_blive_danmaku/command/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .sub import sub_add,sub_delete,sub_list,sub_off,sub_on
from .sub import sub_add,sub_delete,sub_list,sub_off,sub_on,sub_open
from .subscribe import danmaku, live
1 change: 0 additions & 1 deletion nonebot_plugin_blive_danmaku/command/sub/sub_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ async def _(event: MessageEvent, bot: Bot):
type_id = await get_type_id(event)
subs = await db.get_subs(type=event.message_type, type_id=type_id)
msg = "订阅列表:\n\n"
plugin_config = Config.parse_obj(get_driver().config)
for sub in subs:
user = await get_user_info(sub.uid, reqtype="web", proxies=None)
name = user["name"]
Expand Down
20 changes: 20 additions & 0 deletions nonebot_plugin_blive_danmaku/command/sub/sub_open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from nonebot.adapters.onebot.v11.event import MessageEvent
from nonebot.adapters.onebot.v11 import Bot
from nonebot import on_command, get_driver
from ...utils import get_type_id
from ...config import danmaku_config


sub_open = on_command("查看面板", priority=5)
sub_open.__doc__ = """查看面板"""


@sub_open.handle()
async def _(event: MessageEvent, bot: Bot):
"""查看面板"""
driver = get_driver()
host = danmaku_config.danmaku_host if danmaku_config.danmaku_host else f"http://{driver.config.host}:{driver.config.port}"
type_id = await get_type_id(event)
type = event.message_type
url = f"{host}/danmaku/#/?type={type}&type_id={type_id}"
await sub_open.finish(url)
1 change: 1 addition & 0 deletions nonebot_plugin_blive_danmaku/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Config(BaseModel):
danmaku_group_notice: Optional[bool] = Field(False, alias="danmaku_group_notice")
danmaku_host: Optional[str] = Field(None, alias="danmaku_host")

driver = get_driver()
driver_config = driver.config
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-plugin-blive-danmaku"
version = "0.2.0"
version = "0.2.3"
description = "A danmaku plugin for Nonebot2"
authors = ["ricardo <[email protected]>"]
documentation = "https://github.com/zangxx66/nonebot_plugin_blive_danmaku#readme"
Expand Down

0 comments on commit 108e7fb

Please sign in to comment.