nonebot-plugin-jrrp4 0.2.3__py3-none-any.whl

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.
@@ -0,0 +1,174 @@
1
+ from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, GROUP, Message, MessageSegment
2
+ from nonebot.plugin import on_command
3
+ from nonebot.params import CommandArg
4
+ from nonebot import get_plugin_config
5
+ from datetime import date
6
+ import asyncio
7
+ from typing import List
8
+ import time
9
+ from .config import Config
10
+
11
+ from nonebot.plugin import PluginMetadata
12
+
13
+ jrrp_config = get_plugin_config(Config)
14
+
15
+
16
+ __plugin_meta__ = PluginMetadata(
17
+ name="今日人品",
18
+ description="bot给你预测今天的人品值",
19
+ usage="群聊发送 jrrp / 今日人品;可 @成员 查询对方,@机器人 查询机器人。查询者群等级需达到 10 级。",
20
+ type="application",
21
+ homepage="https://github.com/HuParry/nonebot-plugin-jrrp4",
22
+ config=Config,
23
+ supported_adapters={"~onebot.v11"},
24
+ extra={
25
+ "unique_name": "jrrp",
26
+ "example": "今日人品 / jrrp",
27
+ "version": "0.2.3",
28
+ },
29
+ )
30
+
31
+ jrrp = on_command("jrrp", aliases = {"今日人品"}, priority = 50, block = True)
32
+ message: List[dict] = [
33
+ {
34
+ "expr": "jrrp >= 98",
35
+ "start": "!!!!!你今天的人品值是:",
36
+ "end": "!为\"吉吉国王\",这个吉吉国王称号,非你莫属了呀~"
37
+ },
38
+ {
39
+ "expr": "jrrp >= 85",
40
+ "end": "!为\"大吉\",太牛了,您今天人品爆发了!"
41
+ },
42
+ {
43
+ "expr": "jrrp >= 75",
44
+ "end": "!为\"吉\",今天人品很好,快告诉我你是怎么做到的"
45
+ },
46
+ {
47
+ "expr": "jrrp >= 65",
48
+ "end": "!为\"半吉\",今天人品不错,继续保持"
49
+ },
50
+ {
51
+ "expr": "jrrp >= 53",
52
+ "end": "!为\"小吉\",今天人品还行,不过可以更上一个台阶"
53
+ },
54
+ {
55
+ "expr": "jrrp >= 36",
56
+ "end": "!为\"末小吉\",今天人品一般般,继续加油"
57
+ },
58
+ {
59
+ "expr": "jrrp >= 21",
60
+ "end": "!为\"末吉\",今天人品低,凑合着过吧,希望你明天能有点进步"
61
+ },
62
+ {
63
+ "expr": "jrrp >= 1",
64
+ "end": "!为\"凶\",今天人品有点低,换个星球呆一天吧…"
65
+ },
66
+ {
67
+ "expr": "jrrp == 0",
68
+ "end": ",……这个银河系可能已经不适合你了……"
69
+ }
70
+ ]
71
+
72
+ high_list = jrrp_config.jrrp_high_list #列表中的人品爆发!
73
+ low_list = jrrp_config.jrrp_low_list #列表中的人品极低!
74
+ @jrrp.handle()
75
+ async def jrrp_handle(bot: Bot, event: GroupMessageEvent, args: Message = CommandArg()):
76
+ user_id = event.user_id
77
+ group_id = event.group_id
78
+ member_info = await bot.get_group_member_info(
79
+ user_id=user_id,
80
+ group_id=group_id
81
+ )
82
+ level = int(member_info.get('level'))
83
+ if level < 10:
84
+ await jrrp.finish('你的群聊等级不到10级,不告诉你今日人品!')
85
+ if event.is_tome():
86
+ id = event.self_id
87
+ jrrp_num = await get_jrrp(str(id))
88
+ result = await get_msgme(jrrp_num)
89
+ reply = MessageSegment.reply(event.message_id)
90
+ await jrrp.send(reply + result)
91
+ elif len(args) == 0:
92
+ id = event.get_user_id()
93
+ jrrp_num = await get_jrrp(str(id))
94
+ result = await get_msg(jrrp_num)
95
+ reply = MessageSegment.reply(event.message_id)
96
+ await jrrp.send(reply + result)
97
+ else:
98
+ for msg_seg in args:
99
+ if msg_seg.type == "at":
100
+ id = msg_seg.data["qq"]
101
+ jrrp_num = await get_jrrp(str(id))
102
+ result = await get_msghe(jrrp_num)
103
+ await jrrp.send(MessageSegment.at(str(id)) + result)
104
+ await asyncio.sleep(1)
105
+ else:
106
+ print(1)
107
+
108
+ async def rol(num: int, k: int, bits: int = 64):
109
+ b1 = bin(num << k)[2:]
110
+ if len(b1) <= bits:
111
+ return int(b1, 2)
112
+ return int(b1[-bits:], 2)
113
+
114
+ async def get_hash(string: str):
115
+ num = 5381
116
+ num2 = len(string) - 1
117
+ for i in range(num2 + 1):
118
+ num = await rol(num, 5) ^ num ^ ord(string[i])
119
+ return num ^ 12218072394304324399
120
+
121
+ async def get_jrrp(string: str):
122
+ now = time.localtime()
123
+ num = round(abs((await get_hash("".join([
124
+ "asdfgbn",
125
+ str(now.tm_yday),
126
+ "12#3$45",
127
+ str(now.tm_year),
128
+ "IUY"
129
+ ])) / 3 + await get_hash("".join([
130
+ "QWERTY",
131
+ string,
132
+ "0*8&6",
133
+ str(now.tm_mday),
134
+ "kjhg"
135
+ ])) / 3) / 527) % 1001)
136
+ if num >= 970:
137
+ num2 = 100
138
+ else:
139
+ num2 = round(num / 969 * 99)
140
+ if string in high_list:
141
+ num2 = 75 + num2 % 26;
142
+ elif string in low_list:
143
+ num2 = 40 - num2 % 41
144
+ return num2
145
+
146
+ async def get_msg(jrrp):
147
+ start: str = "你今天的人品值是:"
148
+ end: str = "……"
149
+ for msg_obj in message:
150
+ if eval(msg_obj["expr"]):
151
+ start = msg_obj.get("start") if msg_obj.get("start") else start
152
+ end = msg_obj.get("end") if msg_obj.get("end") else end
153
+ lumsg = start + f'{str(jrrp)}/100' + end
154
+ return lumsg
155
+
156
+ async def get_msgme(jrrp):
157
+ start: str = "我今天的人品值是:"
158
+ end: str = "……"
159
+ for msg_obj in message:
160
+ if eval(msg_obj["expr"]):
161
+ start = msg_obj.get("start") if msg_obj.get("start") else start
162
+ end = msg_obj.get("end") if msg_obj.get("end") else end
163
+ lumsg = start + f'{str(jrrp)}/100' + end
164
+ return lumsg
165
+
166
+ async def get_msghe(jrrp):
167
+ start: str = "今天的人品值是:"
168
+ end: str = "……"
169
+ for msg_obj in message:
170
+ if eval(msg_obj["expr"]):
171
+ start = msg_obj.get("start") if msg_obj.get("start") else start
172
+ end = msg_obj.get("end") if msg_obj.get("end") else end
173
+ lumsg = start + f'{str(jrrp)}/100' + end
174
+ return lumsg
@@ -0,0 +1,8 @@
1
+ from typing import List
2
+
3
+ from pydantic import BaseModel, Field
4
+
5
+
6
+ class Config(BaseModel):
7
+ jrrp_high_list: List[str] = Field(default_factory=list)
8
+ jrrp_low_list: List[str] = Field(default_factory=list)
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: nonebot-plugin-jrrp4
3
+ Version: 0.2.3
4
+ Summary: 基于NoneBot2和OneBot V11的今日人品插件
5
+ Author: HuParry
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/HuParry/nonebot-plugin-jrrp4
8
+ Project-URL: Repository, https://github.com/HuParry/nonebot-plugin-jrrp4
9
+ Project-URL: Issues, https://github.com/HuParry/nonebot-plugin-jrrp4/issues
10
+ Keywords: nonebot,nonebot2,onebot,jrrp
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Natural Language :: Chinese (Simplified)
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: nonebot2<3.0.0,>=2.3.0
19
+ Requires-Dist: nonebot-adapter-onebot<3.0.0,>=2.4.0
20
+ Requires-Dist: pydantic<3.0.0,>=1.10.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: build>=1.2.0; extra == "dev"
23
+ Requires-Dist: twine>=5.0.0; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ <div align="center">
27
+ <a href="https://nonebot.dev/store"><img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/nbp_logo.png" width="180" height="180" alt="NoneBotPluginLogo"></a>
28
+ <br>
29
+ <p><img src="https://raw.githubusercontent.com/A-kirami/nonebot-plugin-template/resources/NoneBotPlugin.svg" width="240" alt="NoneBotPluginText"></p>
30
+
31
+ # nonebot-plugin-jrrp4
32
+
33
+ _✨ 基于NoneBot2和OneBot V11的今日人品插件 ✨_
34
+
35
+ <a href="./LICENSE"><img src="https://img.shields.io/github/license/HuParry/nonebot-plugin-jrrp4.svg" alt="license"></a>
36
+ <a href="https://pypi.org/project/nonebot-plugin-jrrp4/"><img src="https://img.shields.io/pypi/v/nonebot-plugin-jrrp4.svg" alt="pypi"></a>
37
+ <img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="python">
38
+
39
+ </div>
40
+
41
+ ## 📖 介绍
42
+
43
+ 在 QQ 群聊中查询今日人品,返回 0~100 的数值和对应评价。同一账号在同一天得到相同结果,每天按机器人运行环境的本地日期更新。
44
+
45
+ 支持查询自己、被 @ 的群成员和机器人,也支持通过配置名单调整指定账号的人品范围。
46
+
47
+ 仅支持群聊,查询者群等级需达到10级。
48
+
49
+ ## 💿 安装
50
+
51
+ <details open>
52
+ <summary>使用 nb-cli 安装</summary>
53
+ 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
54
+
55
+ nb plugin install nonebot-plugin-jrrp4
56
+
57
+ </details>
58
+
59
+ <details>
60
+ <summary>使用包管理器安装</summary>
61
+ 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
62
+
63
+ <details>
64
+ <summary>pip</summary>
65
+
66
+ pip install nonebot-plugin-jrrp4
67
+ </details>
68
+ <details>
69
+ <summary>pdm</summary>
70
+
71
+ pdm add nonebot-plugin-jrrp4
72
+ </details>
73
+ <details>
74
+ <summary>poetry</summary>
75
+
76
+ poetry add nonebot-plugin-jrrp4
77
+ </details>
78
+ <details>
79
+ <summary>conda</summary>
80
+
81
+ conda install nonebot-plugin-jrrp4
82
+ </details>
83
+
84
+ 打开 nonebot2 项目根目录下的 `pyproject.toml` 文件, 在 `[tool.nonebot]` 部分追加写入
85
+
86
+ plugins = ["nonebot_plugin_jrrp4"]
87
+
88
+ </details>
89
+
90
+ ## ⚙️ 配置
91
+
92
+ 无需必填配置。在机器人项目的 `.env` 或实际使用的 `.env.prod` 等环境配置文件中添加以下可选配置,重启机器人生效。示例见 [.env.example](./.env.example)。
93
+
94
+ | 配置项 | 必填 | 默认值 | 类型 | 说明 |
95
+ | --- | --- | --- | --- | --- |
96
+ | `JRRP_HIGH_LIST` | 否 | `[]` | `list[str]` | 人品偏高的 QQ 号列表,通常调整到 75~100 |
97
+ | `JRRP_LOW_LIST` | 否 | `[]` | `list[str]` | 人品偏低的 QQ 号列表,通常调整到 0~40 |
98
+
99
+ ```dotenv
100
+ JRRP_HIGH_LIST=["123456789", "987654321"]
101
+ JRRP_LOW_LIST=["111222333"]
102
+ ```
103
+
104
+ QQ 号需使用字符串形式的 JSON 数组。账号同时出现在两个列表时,优先应用 `JRRP_HIGH_LIST`。当原始计算结果直接命中 100 分时,不应用名单调整,因此低人品名单中的账号也可能获得 100 分。
105
+
106
+ ## 🎉 使用
107
+
108
+ ### 指令表
109
+
110
+ 以下示例假设机器人配置 `COMMAND_START=["/"]`;实际前缀以机器人配置为准。`今日人品` 是 `jrrp` 的别名,可在所有示例中替换使用。
111
+
112
+ | 指令 | 权限 | 需要 @ | 范围 | 说明 |
113
+ | --- | --- | --- | --- | --- |
114
+ | `/jrrp` | 群等级 ≥ 10 的成员 | 否 | 群聊 | 查询自己今日人品 |
115
+ | `/jrrp @成员` | 群等级 ≥ 10 的成员 | 是,@目标成员 | 群聊 | 查询被 @ 成员,可一次 @ 多人 |
116
+ | `/jrrp @机器人` | 群等级 ≥ 10 的成员 | 是,@机器人 | 群聊 | 查询机器人今日人品 |
117
+
118
+ @ 需使用 QQ 的实际 @ 消息,纯文本 QQ 号不会触发查询。查询者等级不足时会提示“你的群聊等级不到10级,不告诉你今日人品!”。当消息被适配器识别为发给机器人(`to_me`)时,优先查询机器人自身。
119
+
120
+ ### 回复示例
121
+
122
+ ```text
123
+ 你今天的人品值是:88/100!为"大吉",太牛了,您今天人品爆发了!
124
+ ```
125
+
126
+ ## 📦 发布说明
127
+
128
+ 仓库提供 [PyPI 发布工作流](./.github/workflows/pypi-publish.yml),使用 PEP 621 格式的 [pyproject.toml](./pyproject.toml) 构建 wheel 和源码包,并在上传前校验包信息。
129
+
130
+ 需要维护者自行完成的远程配置:
131
+
132
+ 1. 将仓库发布到 `HuParry/nonebot-plugin-jrrp4`,并将本地 Git remote 指向自己的仓库。
133
+ 2. 在 [PyPI](https://pypi.org/manage/account/#api-tokens) 创建 API Token,并在 GitHub 仓库的 Settings → Secrets and variables → Actions 中添加名为 `PYPI_API_TOKEN` 的 Repository secret。
134
+ 3. 发布新版本前修改 `pyproject.toml` 中的 `project.version` 和插件 `__plugin_meta__.extra` 中的 `version`,保持一致,并提交代码。
135
+ 4. 创建并推送对应版本的标签,触发工作流。例如当前版本:
136
+
137
+ ```bash
138
+ git tag v0.2.3
139
+ git push origin v0.2.3
140
+ ```
141
+
142
+ 标签版本必须与 `project.version` 一致,允许使用 `v` 前缀。工作流也可在 GitHub Actions 中手动运行;同一 PyPI 版本不能重复上传。
143
+
144
+ 如需提交 NoneBot 插件商店,维护者还需按 [官方发布指引](https://nonebot.dev/docs/developer/plugin-publishing) 操作;项目名为 `nonebot-plugin-jrrp4`,插件模块名为 `nonebot_plugin_jrrp4`。
145
+
146
+ ## 📄 开源协议
147
+
148
+ 本项目采用 [MIT License](./LICENSE)。
@@ -0,0 +1,7 @@
1
+ nonebot_plugin_jrrp4/__init__.py,sha256=UZkOXljebc1hYjxvH8Z1TDr1nN_773dzCwSdUXd2Kx4,5559
2
+ nonebot_plugin_jrrp4/config.py,sha256=qrUxW5oX2Op12nDWDF66klKEaEhKJoV5wCpkYlRT2RE,209
3
+ nonebot_plugin_jrrp4-0.2.3.dist-info/licenses/LICENSE,sha256=aB_DjQgXRgC4FrmqfHZomLaYN0-mroek_S2VLDa0cyM,1064
4
+ nonebot_plugin_jrrp4-0.2.3.dist-info/METADATA,sha256=AgBkBx4Ag8AiyJZ6oG9qXuo9DiTkq0T77EUogbvZhoA,6181
5
+ nonebot_plugin_jrrp4-0.2.3.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
6
+ nonebot_plugin_jrrp4-0.2.3.dist-info/top_level.txt,sha256=BwcpIEf8XtIBWkglOPLapdqoTKbioFx9DIM5m09qpas,21
7
+ nonebot_plugin_jrrp4-0.2.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HuParry
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 @@
1
+ nonebot_plugin_jrrp4