nonebot-plugin-areusleepy 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nonebot_plugin_areusleepy-0.0.1/LICENSE +21 -0
- nonebot_plugin_areusleepy-0.0.1/PKG-INFO +183 -0
- nonebot_plugin_areusleepy-0.0.1/README.md +170 -0
- nonebot_plugin_areusleepy-0.0.1/nonebot_plugin_areusleepy/__init__.py +23 -0
- nonebot_plugin_areusleepy-0.0.1/nonebot_plugin_areusleepy/__main__.py +83 -0
- nonebot_plugin_areusleepy-0.0.1/nonebot_plugin_areusleepy/config.py +5 -0
- nonebot_plugin_areusleepy-0.0.1/nonebot_plugin_areusleepy/getsleepy.py +90 -0
- nonebot_plugin_areusleepy-0.0.1/pyproject.toml +37 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Murasame
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,183 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: nonebot-plugin-areusleepy
|
3
|
+
Version: 0.0.1
|
4
|
+
Summary: Let bot look!!!
|
5
|
+
Author-Email: Murasame <congyu@sbhfy.cn>
|
6
|
+
License: MIT
|
7
|
+
Project-URL: homepage, https://github.com/Murasame-Dev/nonebot-plugin-areusleepy
|
8
|
+
Requires-Python: <4.0,>=3.9
|
9
|
+
Requires-Dist: nonebot2>=2.4.1
|
10
|
+
Requires-Dist: nonebot-plugin-alconna>=0.54.2
|
11
|
+
Requires-Dist: httpx>=0.28.1
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
|
14
|
+
<!-- markdownlint-disable MD031 MD033 MD036 MD041 -->
|
15
|
+
|
16
|
+
<div align="center">
|
17
|
+
|
18
|
+
<a href="https://v2.nonebot.dev/store">
|
19
|
+
<img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo">
|
20
|
+
</a>
|
21
|
+
|
22
|
+
<p>
|
23
|
+
<img src="https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/plugin.svg" alt="NoneBotPluginText">
|
24
|
+
</p>
|
25
|
+
|
26
|
+
# NoneBot-Plugin-AreUSleepy
|
27
|
+
|
28
|
+
_✨基于 [sleepy-project/sleepy](https://github.com/sleepy-project/sleepy) 项目的状态查询插件! ✨_
|
29
|
+
|
30
|
+
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
31
|
+
<a href="https://pdm.fming.dev">
|
32
|
+
<img src="https://img.shields.io/badge/pdm-managed-blueviolet" alt="pdm-managed">
|
33
|
+
</a>
|
34
|
+
<a href="https://wakatime.com/badge/user/b61b0f9a-f40b-4c82-bc51-0a75c67bfccf/project/f4778875-45a4-4688-8e1b-b8c844440abb">
|
35
|
+
<img src="https://wakatime.com/badge/user/b61b0f9a-f40b-4c82-bc51-0a75c67bfccf/project/f4778875-45a4-4688-8e1b-b8c844440abb.svg" alt="wakatime">
|
36
|
+
</a>
|
37
|
+
|
38
|
+
<br />
|
39
|
+
|
40
|
+
<!-- <a href="https://pydantic.dev">
|
41
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v1.json" alt="Pydantic Version 1" >
|
42
|
+
</a> -->
|
43
|
+
|
44
|
+
<!-- <a href="https://pydantic.dev">
|
45
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json" alt="Pydantic Version 2" >
|
46
|
+
</a> -->
|
47
|
+
|
48
|
+
<a href="https://pydantic.dev">
|
49
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/pyd-v1-or-v2.json" alt="Pydantic Version 1 Or 2" >
|
50
|
+
</a>
|
51
|
+
<a href="./LICENSE">
|
52
|
+
<img src="https://img.shields.io/github/license/lgc-NB2Dev/nonebot-plugin-example.svg" alt="license">
|
53
|
+
</a>
|
54
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-example">
|
55
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-example.svg" alt="pypi">
|
56
|
+
</a>
|
57
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-example">
|
58
|
+
<img src="https://img.shields.io/pypi/dm/nonebot-plugin-example" alt="pypi download">
|
59
|
+
</a>
|
60
|
+
|
61
|
+
<br />
|
62
|
+
|
63
|
+
<a href="https://registry.nonebot.dev/plugin/nonebot-plugin-example:nonebot_plugin_example">
|
64
|
+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-example" alt="NoneBot Registry">
|
65
|
+
</a>
|
66
|
+
<a href="https://registry.nonebot.dev/plugin/nonebot-plugin-example:nonebot_plugin_example">
|
67
|
+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-example" alt="Supported Adapters">
|
68
|
+
</a>
|
69
|
+
|
70
|
+
</div>
|
71
|
+
|
72
|
+
## 📖 介绍
|
73
|
+
|
74
|
+
此插件可以发送在 [sleepy-project/sleepy](https://github.com/sleepy-project/sleepy) 目前的状态信息,可以显示用户的设备是否在使用中,正在听的歌曲(支持情况以 sleepy 项目为准),支持多设备状态列表
|
75
|
+
|
76
|
+
## 💿 安装
|
77
|
+
|
78
|
+
以下提到的方法 任选**其一** 即可
|
79
|
+
|
80
|
+
<details open>
|
81
|
+
<summary>[推荐] 使用 nb-cli 安装</summary>
|
82
|
+
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
|
83
|
+
|
84
|
+
```bash
|
85
|
+
nb plugin install nonebot-plugin-areusleepy
|
86
|
+
```
|
87
|
+
|
88
|
+
</details>
|
89
|
+
|
90
|
+
<details>
|
91
|
+
<summary>使用包管理器安装</summary>
|
92
|
+
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
|
93
|
+
|
94
|
+
<details>
|
95
|
+
<summary>pip</summary>
|
96
|
+
|
97
|
+
```bash
|
98
|
+
pip install nonebot-plugin-areusleepy
|
99
|
+
```
|
100
|
+
|
101
|
+
</details>
|
102
|
+
<details>
|
103
|
+
<summary>pdm</summary>
|
104
|
+
|
105
|
+
```bash
|
106
|
+
pdm add nonebot-nonebot-plugin-areusleepy
|
107
|
+
```
|
108
|
+
|
109
|
+
</details>
|
110
|
+
<details>
|
111
|
+
<summary>poetry</summary>
|
112
|
+
|
113
|
+
```bash
|
114
|
+
poetry add nonebot-plugin-areusleepy
|
115
|
+
```
|
116
|
+
|
117
|
+
</details>
|
118
|
+
<details>
|
119
|
+
<summary>conda</summary>
|
120
|
+
|
121
|
+
```bash
|
122
|
+
conda install nonebot-plugin-areusleepy
|
123
|
+
```
|
124
|
+
|
125
|
+
</details>
|
126
|
+
<details>
|
127
|
+
<summary>uv</summary>
|
128
|
+
|
129
|
+
```bash
|
130
|
+
uv add nonebot-plugin-areusleepy
|
131
|
+
```
|
132
|
+
|
133
|
+
</details>
|
134
|
+
|
135
|
+
打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分的 `plugins` 项里追加写入
|
136
|
+
|
137
|
+
```toml
|
138
|
+
[tool.nonebot]
|
139
|
+
plugins = [
|
140
|
+
# ...
|
141
|
+
"nonebot_plugin_areusleepy"
|
142
|
+
]
|
143
|
+
```
|
144
|
+
|
145
|
+
</details>
|
146
|
+
|
147
|
+
## ⚙️ 配置
|
148
|
+
|
149
|
+
#### `sleepyurl` - /getsleepy 使用的默认地址
|
150
|
+
|
151
|
+
默认: "http://127.0.0.1:9010"
|
152
|
+
|
153
|
+
****必须要有http://或https://****
|
154
|
+
|
155
|
+
## 🎉 使用
|
156
|
+
|
157
|
+
### 指令表
|
158
|
+
|
159
|
+
#### `areusleepy` - 查询默认配置的状态信息
|
160
|
+
|
161
|
+
查询配置文件内的网站信息并输出
|
162
|
+
|
163
|
+
#### `getsleepy url` - 查询其他站点的状态信息
|
164
|
+
|
165
|
+
url 可填写为任意地址,**但需要注意http://或https://**
|
166
|
+
|
167
|
+
### 效果图
|
168
|
+
|
169
|
+

|
170
|
+
|
171
|
+
## 📞 联系
|
172
|
+
|
173
|
+
TG群组:[点此加入](https://t.me/LoveMurasame)
|
174
|
+
吹水群:[1049319982](https://qm.qq.com/q/DfTsIDXuc8)
|
175
|
+
邮箱:<congyu@sbhfy.cn>
|
176
|
+
|
177
|
+
## 💡 鸣谢
|
178
|
+
|
179
|
+
[sleepy-project/sleepy: Are you sleeping?](https://github.com/sleepy-project/sleepy) - 提供灵感,感谢开发者 [wyf9](https://github.com/wyf9) 的耐心指导
|
180
|
+
|
181
|
+
## 📝 更新日志
|
182
|
+
|
183
|
+
芝士刚刚发布的插件,还没有更新日志的说 qwq~
|
@@ -0,0 +1,170 @@
|
|
1
|
+
<!-- markdownlint-disable MD031 MD033 MD036 MD041 -->
|
2
|
+
|
3
|
+
<div align="center">
|
4
|
+
|
5
|
+
<a href="https://v2.nonebot.dev/store">
|
6
|
+
<img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo">
|
7
|
+
</a>
|
8
|
+
|
9
|
+
<p>
|
10
|
+
<img src="https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/plugin.svg" alt="NoneBotPluginText">
|
11
|
+
</p>
|
12
|
+
|
13
|
+
# NoneBot-Plugin-AreUSleepy
|
14
|
+
|
15
|
+
_✨基于 [sleepy-project/sleepy](https://github.com/sleepy-project/sleepy) 项目的状态查询插件! ✨_
|
16
|
+
|
17
|
+
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
|
18
|
+
<a href="https://pdm.fming.dev">
|
19
|
+
<img src="https://img.shields.io/badge/pdm-managed-blueviolet" alt="pdm-managed">
|
20
|
+
</a>
|
21
|
+
<a href="https://wakatime.com/badge/user/b61b0f9a-f40b-4c82-bc51-0a75c67bfccf/project/f4778875-45a4-4688-8e1b-b8c844440abb">
|
22
|
+
<img src="https://wakatime.com/badge/user/b61b0f9a-f40b-4c82-bc51-0a75c67bfccf/project/f4778875-45a4-4688-8e1b-b8c844440abb.svg" alt="wakatime">
|
23
|
+
</a>
|
24
|
+
|
25
|
+
<br />
|
26
|
+
|
27
|
+
<!-- <a href="https://pydantic.dev">
|
28
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v1.json" alt="Pydantic Version 1" >
|
29
|
+
</a> -->
|
30
|
+
|
31
|
+
<!-- <a href="https://pydantic.dev">
|
32
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/pydantic/pydantic/main/docs/badge/v2.json" alt="Pydantic Version 2" >
|
33
|
+
</a> -->
|
34
|
+
|
35
|
+
<a href="https://pydantic.dev">
|
36
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/lgc-NB2Dev/readme/main/template/pyd-v1-or-v2.json" alt="Pydantic Version 1 Or 2" >
|
37
|
+
</a>
|
38
|
+
<a href="./LICENSE">
|
39
|
+
<img src="https://img.shields.io/github/license/lgc-NB2Dev/nonebot-plugin-example.svg" alt="license">
|
40
|
+
</a>
|
41
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-example">
|
42
|
+
<img src="https://img.shields.io/pypi/v/nonebot-plugin-example.svg" alt="pypi">
|
43
|
+
</a>
|
44
|
+
<a href="https://pypi.python.org/pypi/nonebot-plugin-example">
|
45
|
+
<img src="https://img.shields.io/pypi/dm/nonebot-plugin-example" alt="pypi download">
|
46
|
+
</a>
|
47
|
+
|
48
|
+
<br />
|
49
|
+
|
50
|
+
<a href="https://registry.nonebot.dev/plugin/nonebot-plugin-example:nonebot_plugin_example">
|
51
|
+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-example" alt="NoneBot Registry">
|
52
|
+
</a>
|
53
|
+
<a href="https://registry.nonebot.dev/plugin/nonebot-plugin-example:nonebot_plugin_example">
|
54
|
+
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-example" alt="Supported Adapters">
|
55
|
+
</a>
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
## 📖 介绍
|
60
|
+
|
61
|
+
此插件可以发送在 [sleepy-project/sleepy](https://github.com/sleepy-project/sleepy) 目前的状态信息,可以显示用户的设备是否在使用中,正在听的歌曲(支持情况以 sleepy 项目为准),支持多设备状态列表
|
62
|
+
|
63
|
+
## 💿 安装
|
64
|
+
|
65
|
+
以下提到的方法 任选**其一** 即可
|
66
|
+
|
67
|
+
<details open>
|
68
|
+
<summary>[推荐] 使用 nb-cli 安装</summary>
|
69
|
+
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
|
70
|
+
|
71
|
+
```bash
|
72
|
+
nb plugin install nonebot-plugin-areusleepy
|
73
|
+
```
|
74
|
+
|
75
|
+
</details>
|
76
|
+
|
77
|
+
<details>
|
78
|
+
<summary>使用包管理器安装</summary>
|
79
|
+
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
|
80
|
+
|
81
|
+
<details>
|
82
|
+
<summary>pip</summary>
|
83
|
+
|
84
|
+
```bash
|
85
|
+
pip install nonebot-plugin-areusleepy
|
86
|
+
```
|
87
|
+
|
88
|
+
</details>
|
89
|
+
<details>
|
90
|
+
<summary>pdm</summary>
|
91
|
+
|
92
|
+
```bash
|
93
|
+
pdm add nonebot-nonebot-plugin-areusleepy
|
94
|
+
```
|
95
|
+
|
96
|
+
</details>
|
97
|
+
<details>
|
98
|
+
<summary>poetry</summary>
|
99
|
+
|
100
|
+
```bash
|
101
|
+
poetry add nonebot-plugin-areusleepy
|
102
|
+
```
|
103
|
+
|
104
|
+
</details>
|
105
|
+
<details>
|
106
|
+
<summary>conda</summary>
|
107
|
+
|
108
|
+
```bash
|
109
|
+
conda install nonebot-plugin-areusleepy
|
110
|
+
```
|
111
|
+
|
112
|
+
</details>
|
113
|
+
<details>
|
114
|
+
<summary>uv</summary>
|
115
|
+
|
116
|
+
```bash
|
117
|
+
uv add nonebot-plugin-areusleepy
|
118
|
+
```
|
119
|
+
|
120
|
+
</details>
|
121
|
+
|
122
|
+
打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分的 `plugins` 项里追加写入
|
123
|
+
|
124
|
+
```toml
|
125
|
+
[tool.nonebot]
|
126
|
+
plugins = [
|
127
|
+
# ...
|
128
|
+
"nonebot_plugin_areusleepy"
|
129
|
+
]
|
130
|
+
```
|
131
|
+
|
132
|
+
</details>
|
133
|
+
|
134
|
+
## ⚙️ 配置
|
135
|
+
|
136
|
+
#### `sleepyurl` - /getsleepy 使用的默认地址
|
137
|
+
|
138
|
+
默认: "http://127.0.0.1:9010"
|
139
|
+
|
140
|
+
****必须要有http://或https://****
|
141
|
+
|
142
|
+
## 🎉 使用
|
143
|
+
|
144
|
+
### 指令表
|
145
|
+
|
146
|
+
#### `areusleepy` - 查询默认配置的状态信息
|
147
|
+
|
148
|
+
查询配置文件内的网站信息并输出
|
149
|
+
|
150
|
+
#### `getsleepy url` - 查询其他站点的状态信息
|
151
|
+
|
152
|
+
url 可填写为任意地址,**但需要注意http://或https://**
|
153
|
+
|
154
|
+
### 效果图
|
155
|
+
|
156
|
+

|
157
|
+
|
158
|
+
## 📞 联系
|
159
|
+
|
160
|
+
TG群组:[点此加入](https://t.me/LoveMurasame)
|
161
|
+
吹水群:[1049319982](https://qm.qq.com/q/DfTsIDXuc8)
|
162
|
+
邮箱:<congyu@sbhfy.cn>
|
163
|
+
|
164
|
+
## 💡 鸣谢
|
165
|
+
|
166
|
+
[sleepy-project/sleepy: Are you sleeping?](https://github.com/sleepy-project/sleepy) - 提供灵感,感谢开发者 [wyf9](https://github.com/wyf9) 的耐心指导
|
167
|
+
|
168
|
+
## 📝 更新日志
|
169
|
+
|
170
|
+
芝士刚刚发布的插件,还没有更新日志的说 qwq~
|
@@ -0,0 +1,23 @@
|
|
1
|
+
from nonebot import get_plugin_config
|
2
|
+
from nonebot.plugin import PluginMetadata, inherit_supported_adapters, require
|
3
|
+
|
4
|
+
require("nonebot_plugin_alconna")
|
5
|
+
|
6
|
+
from . import __main__ as __main__
|
7
|
+
from . import getsleepy as getsleepy
|
8
|
+
|
9
|
+
from .config import Config
|
10
|
+
|
11
|
+
__version__ = "0.0.1"
|
12
|
+
__plugin_meta__ = PluginMetadata(
|
13
|
+
name="AreYouSleepy",
|
14
|
+
description="基于 sleepy-project/sleepy 项目的状态查询插件!",
|
15
|
+
usage="/areusleepy /getsleepy url",
|
16
|
+
type="application",
|
17
|
+
homepage="https://github.com/Murasame-Dev/nonebot-plugin-areusleepy",
|
18
|
+
supported_adapters=inherit_supported_adapters("nonebot_plugin_alconna"),
|
19
|
+
config=Config,
|
20
|
+
)
|
21
|
+
|
22
|
+
config = get_plugin_config(Config)
|
23
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
from nonebot import on_command
|
2
|
+
from nonebot.matcher import Matcher
|
3
|
+
from nonebot.params import CommandArg
|
4
|
+
from nonebot.adapters import Event as BaseEvent, Message
|
5
|
+
from nonebot import get_plugin_config, get_bot
|
6
|
+
|
7
|
+
import httpx
|
8
|
+
|
9
|
+
from nonebot_plugin_alconna.uniseg import UniMessage
|
10
|
+
from typing import Optional
|
11
|
+
|
12
|
+
from .config import Config
|
13
|
+
|
14
|
+
# 获取插件配置
|
15
|
+
plugin_config = get_plugin_config(Config)
|
16
|
+
|
17
|
+
fetch_status = on_command(
|
18
|
+
"areusleepy",
|
19
|
+
aliases={"获取Sleepy状态"}
|
20
|
+
)
|
21
|
+
|
22
|
+
async def get_status_data() -> Optional[dict]:
|
23
|
+
url = f"{plugin_config.sleepyurl}/query"
|
24
|
+
try:
|
25
|
+
async with httpx.AsyncClient(timeout=10.0) as client:
|
26
|
+
response = await client.get(url)
|
27
|
+
if response.status_code == 200:
|
28
|
+
return response.json()
|
29
|
+
return None
|
30
|
+
except Exception as e:
|
31
|
+
return None
|
32
|
+
|
33
|
+
|
34
|
+
def format_device_info(device_data: dict) -> str:
|
35
|
+
device_lines = []
|
36
|
+
for device_name, info in device_data.items():
|
37
|
+
using_status = "✅ 使用中" if info.get('using', False) else "❌ 未使用"
|
38
|
+
device_lines.append(
|
39
|
+
f" - {info.get('show_name', device_name)}: {using_status}\n"
|
40
|
+
f" 应用: {info.get('app_name')}"
|
41
|
+
)
|
42
|
+
return "\n".join(device_lines)
|
43
|
+
|
44
|
+
async def create_status_message(data: dict) -> UniMessage:
|
45
|
+
msg = UniMessage()
|
46
|
+
|
47
|
+
# info
|
48
|
+
if 'info' in data and isinstance(data['info'], dict):
|
49
|
+
info = data['info']
|
50
|
+
msg += (
|
51
|
+
f"👋你好,{plugin_config.sleepyurl}\n"
|
52
|
+
f"🌐 个人信息:\n"
|
53
|
+
f" 状态: {info.get('name')}\n"
|
54
|
+
f" {info.get('desc')}\n"
|
55
|
+
)
|
56
|
+
|
57
|
+
# device info
|
58
|
+
if 'device' in data and isinstance(data['device'], dict):
|
59
|
+
msg += "\n\n📱 设备使用情况:\n"
|
60
|
+
msg += format_device_info(data['device'])
|
61
|
+
|
62
|
+
# 最后更新时间
|
63
|
+
if 'last_updated' in data:
|
64
|
+
msg += f"\n\n⏱ 最后更新: {data['last_updated']}"
|
65
|
+
|
66
|
+
return msg
|
67
|
+
|
68
|
+
@fetch_status.handle()
|
69
|
+
async def _(arg_msg: Message = CommandArg()):
|
70
|
+
"""处理queryFetch命令"""
|
71
|
+
await fetch_status.send("正在获取状态信息,请稍候...")
|
72
|
+
|
73
|
+
# 获取状态数据
|
74
|
+
data = await get_status_data()
|
75
|
+
|
76
|
+
# 如果获取数据失败,返回错误信息
|
77
|
+
if data is None:
|
78
|
+
await fetch_status.send("获取状态信息失败,请稍后重试")
|
79
|
+
return
|
80
|
+
|
81
|
+
# 生成并发送消息
|
82
|
+
msg = await create_status_message(data)
|
83
|
+
await fetch_status.send(str(msg))
|
@@ -0,0 +1,90 @@
|
|
1
|
+
from nonebot import on_command
|
2
|
+
from nonebot.matcher import Matcher
|
3
|
+
from nonebot.params import CommandArg
|
4
|
+
from nonebot.adapters import Event as BaseEvent, Message
|
5
|
+
from nonebot import get_plugin_config, get_bot
|
6
|
+
|
7
|
+
import httpx
|
8
|
+
|
9
|
+
from nonebot_plugin_alconna.uniseg import UniMessage
|
10
|
+
from typing import Optional
|
11
|
+
|
12
|
+
from .config import Config
|
13
|
+
|
14
|
+
# 获取插件配置
|
15
|
+
plugin_config = get_plugin_config(Config)
|
16
|
+
|
17
|
+
get_other_status = on_command(
|
18
|
+
"getsleepy",
|
19
|
+
aliases={"获取其他Sleepy状态"}
|
20
|
+
)
|
21
|
+
|
22
|
+
async def get_status_data(custom_url: Optional[str] = None) -> Optional[dict]:
|
23
|
+
url = f"{custom_url or plugin_config.sleepyurl}/query"
|
24
|
+
try:
|
25
|
+
async with httpx.AsyncClient(timeout=10.0) as client:
|
26
|
+
response = await client.get(url)
|
27
|
+
if response.status_code == 200:
|
28
|
+
return response.json()
|
29
|
+
return None
|
30
|
+
except Exception as e:
|
31
|
+
return None
|
32
|
+
|
33
|
+
|
34
|
+
def format_device_info(device_data: dict) -> str:
|
35
|
+
device_lines = []
|
36
|
+
for device_name, info in device_data.items():
|
37
|
+
using_status = "✅ 使用中" if info.get('using', False) else "❌ 未使用"
|
38
|
+
device_lines.append(
|
39
|
+
f" - {info.get('show_name', device_name)}: {using_status}\n"
|
40
|
+
f" 应用: {info.get('app_name')}"
|
41
|
+
)
|
42
|
+
return "\n".join(device_lines)
|
43
|
+
|
44
|
+
async def create_status_message(data: dict, url: Optional[str] = None) -> UniMessage:
|
45
|
+
msg = UniMessage()
|
46
|
+
|
47
|
+
# info
|
48
|
+
if 'info' in data and isinstance(data['info'], dict):
|
49
|
+
info = data['info']
|
50
|
+
display_url = url or plugin_config.sleepyurl
|
51
|
+
msg += (
|
52
|
+
f"👋你好 {display_url}\n"
|
53
|
+
f"🌐 个人信息:\n"
|
54
|
+
f" 状态: {info.get('name')}\n"
|
55
|
+
f" {info.get('desc')}\n"
|
56
|
+
)
|
57
|
+
|
58
|
+
# device info
|
59
|
+
if 'device' in data and isinstance(data['device'], dict):
|
60
|
+
msg += "\n\n📱 设备使用情况:\n"
|
61
|
+
msg += format_device_info(data['device'])
|
62
|
+
|
63
|
+
# 最后更新时间
|
64
|
+
if 'last_updated' in data:
|
65
|
+
msg += f"\n\n⏱ 最后更新: {data['last_updated']}"
|
66
|
+
|
67
|
+
return msg
|
68
|
+
|
69
|
+
@get_other_status.handle()
|
70
|
+
async def handle_get_other_status(arg_msg: Message = CommandArg()):
|
71
|
+
"""处理getsleepy命令"""
|
72
|
+
# 获取URL参数
|
73
|
+
url = arg_msg.extract_plain_text().strip()
|
74
|
+
if not url:
|
75
|
+
await get_other_status.send("请提供要查询的URL\n用法: /getsleepy url")
|
76
|
+
return
|
77
|
+
|
78
|
+
await get_other_status.send("正在获取状态信息,请稍候...")
|
79
|
+
|
80
|
+
# 获取状态数据
|
81
|
+
data = await get_status_data(url)
|
82
|
+
|
83
|
+
# 如果获取数据失败,返回错误信息
|
84
|
+
if data is None:
|
85
|
+
await get_other_status.send("获取状态信息失败,请检查URL是否正确")
|
86
|
+
return
|
87
|
+
|
88
|
+
# 生成并发送消息
|
89
|
+
msg = await create_status_message(data, url)
|
90
|
+
await get_other_status.send(str(msg))
|
@@ -0,0 +1,37 @@
|
|
1
|
+
[project]
|
2
|
+
name = "nonebot-plugin-areusleepy"
|
3
|
+
dynamic = []
|
4
|
+
description = "Let bot look!!!"
|
5
|
+
authors = [
|
6
|
+
{ name = "Murasame", email = "congyu@sbhfy.cn" },
|
7
|
+
]
|
8
|
+
requires-python = ">=3.9,<4.0"
|
9
|
+
readme = "README.md"
|
10
|
+
dependencies = [
|
11
|
+
"nonebot2>=2.4.1",
|
12
|
+
"nonebot-plugin-alconna>=0.54.2",
|
13
|
+
"httpx>=0.28.1",
|
14
|
+
]
|
15
|
+
version = "0.0.1"
|
16
|
+
|
17
|
+
[project.license]
|
18
|
+
text = "MIT"
|
19
|
+
|
20
|
+
[project.urls]
|
21
|
+
homepage = "https://github.com/Murasame-Dev/nonebot-plugin-areusleepy"
|
22
|
+
|
23
|
+
[dependency-groups]
|
24
|
+
dev = []
|
25
|
+
|
26
|
+
[build-system]
|
27
|
+
requires = [
|
28
|
+
"pdm-backend",
|
29
|
+
]
|
30
|
+
build-backend = "pdm.backend"
|
31
|
+
|
32
|
+
[tool.pdm.build]
|
33
|
+
includes = []
|
34
|
+
|
35
|
+
[tool.pdm.version]
|
36
|
+
source = "file"
|
37
|
+
path = "nonebot_plugin_areusleepy/__init__.py"
|