nonebot-plugin-helper-recall 0.1.0__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.
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: nonebot-plugin-helper-recall
3
+ Version: 0.1.0
4
+ Summary: 帮助普通群员撤回自己超时无法撤回的消息
5
+ Author-email: Wojusensei <3442006415@qq.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Wojusensei/nonebot-plugin-helper-recall
8
+ Classifier: Programming Language :: Python :: 3
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: nonebot2>=2.3.0
12
+ Requires-Dist: nonebot-adapter-onebot>=2.0.0
13
+ Requires-Dist: nonebot-plugin-alconna>=0.3.0
14
+ Requires-Dist: nonebot-plugin-localstore>=0.5.0
15
+
16
+ # nonebot-plugin-helper-recall
17
+
18
+ ✨ 帮撤回插件 ✨
19
+
20
+ 帮助普通群员撤回自己因超时无法撤回的消息,需要bot被群主授予管理员权限(想给bot群主我也没意见(bushi))
21
+
22
+ ## 功能
23
+
24
+ - 引用自己发送的消息,发送 `/撤回` 指令
25
+ - Bot 尝试撤回该消息
26
+ - 撤回成功后在指令消息上添加 🎉 表情
27
+
28
+ ## 安装(指令二选一,无区别)
29
+
30
+ ```bash
31
+ nb plugin install nonebot-plugin-helper-recall
32
+ pip install nonebot-plugin-helper-recall
33
+ ```
34
+
35
+ ## 使用
36
+
37
+ 1. 确保 Bot 是群管理员
38
+ 2. 群员引用自己发送的任意消息(包括超时的)
39
+ 3. 在同一条消息中发送 `/撤回`
40
+ 4. Bot 会撤回那条被引用的消息
41
+
42
+ ## 注意事项
43
+
44
+ - 仅支持撤回自己的消息
45
+ - 如果消息已超过 QQ 可撤回时间,会提示失败
46
+ - 需要 Bot 有管理员权限
47
+
48
+ ## 配置
49
+
50
+ 无需配置,即装即用
51
+
52
+ ## 开源协议
53
+
54
+ MIT
@@ -0,0 +1,39 @@
1
+ # nonebot-plugin-helper-recall
2
+
3
+ ✨ 帮撤回插件 ✨
4
+
5
+ 帮助普通群员撤回自己因超时无法撤回的消息,需要bot被群主授予管理员权限(想给bot群主我也没意见(bushi))
6
+
7
+ ## 功能
8
+
9
+ - 引用自己发送的消息,发送 `/撤回` 指令
10
+ - Bot 尝试撤回该消息
11
+ - 撤回成功后在指令消息上添加 🎉 表情
12
+
13
+ ## 安装(指令二选一,无区别)
14
+
15
+ ```bash
16
+ nb plugin install nonebot-plugin-helper-recall
17
+ pip install nonebot-plugin-helper-recall
18
+ ```
19
+
20
+ ## 使用
21
+
22
+ 1. 确保 Bot 是群管理员
23
+ 2. 群员引用自己发送的任意消息(包括超时的)
24
+ 3. 在同一条消息中发送 `/撤回`
25
+ 4. Bot 会撤回那条被引用的消息
26
+
27
+ ## 注意事项
28
+
29
+ - 仅支持撤回自己的消息
30
+ - 如果消息已超过 QQ 可撤回时间,会提示失败
31
+ - 需要 Bot 有管理员权限
32
+
33
+ ## 配置
34
+
35
+ 无需配置,即装即用
36
+
37
+ ## 开源协议
38
+
39
+ MIT
@@ -0,0 +1,108 @@
1
+ from nonebot import require, get_plugin_config, on_command
2
+ from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent
3
+ from nonebot.params import CommandArg
4
+ from nonebot.plugin import PluginMetadata
5
+ from nonebot.log import logger
6
+
7
+ from .config import Config
8
+
9
+ require("nonebot_plugin_localstore")
10
+ require("nonebot_plugin_alconna")
11
+ from nonebot_plugin_alconna import message_reaction
12
+
13
+ # ----------------------------------------------------------------
14
+ # 插件元数据
15
+ # ----------------------------------------------------------------
16
+
17
+ __plugin_meta__ = PluginMetadata(
18
+ name="帮撤回",
19
+ description="帮助普通群员撤回自己超时无法撤回的消息",
20
+ usage="引用自己发送的消息,并发送「/撤回」指令",
21
+ type="application",
22
+ homepage="https://github.com/Wojusensei/nonebot-plugin-helper-recall",
23
+ config=Config,
24
+ supported_adapters={"~onebot.v11"},
25
+ )
26
+
27
+ # ----------------------------------------------------------------
28
+ # 读取配置
29
+ # ----------------------------------------------------------------
30
+
31
+ plugin_config = get_plugin_config(Config)
32
+
33
+ # ----------------------------------------------------------------
34
+ # 命令注册
35
+ # ----------------------------------------------------------------
36
+
37
+ recall = on_command("/撤回", aliases={"撤回"}, priority=10, block=True)
38
+
39
+
40
+ # ----------------------------------------------------------------
41
+ # 撤回命令处理函数
42
+ # ----------------------------------------------------------------
43
+
44
+ @recall.handle()
45
+ async def handle_recall(bot: Bot, event: GroupMessageEvent, args: str = CommandArg()):
46
+ # ----------------------------------------------------------------
47
+ # 获取引用消息
48
+ # ----------------------------------------------------------------
49
+ reply = event.reply
50
+ if not reply:
51
+ await recall.finish("请引用一条消息后再使用 /撤回 命令")
52
+
53
+ # ----------------------------------------------------------------
54
+ # 检查是否为那个用户发送的消息
55
+ # ----------------------------------------------------------------
56
+
57
+ if reply.sender.user_id != event.user_id:
58
+ await recall.finish("仅支持撤回自己的消息哦~")
59
+
60
+ # ----------------------------------------------------------------
61
+ # 检查bot是否有管理员权限
62
+ # ----------------------------------------------------------------
63
+ try:
64
+ bot_info = await bot.get_group_member_info(group_id=event.group_id, user_id=int(bot.self_id))
65
+ if bot_info.get("role") not in ("admin", "owner"):
66
+ await recall.finish("群主没有给我配置撤回权限捏")
67
+ except Exception as e:
68
+ logger.error(f"获取bot权限失败: {e}")
69
+ await recall.finish("权限检查失败,请稍后再试")
70
+
71
+ # ----------------------------------------------------------------
72
+ # 表示正在处理中
73
+ # ----------------------------------------------------------------
74
+ try:
75
+ await message_reaction(
76
+ event=event,
77
+ reaction="/whl",
78
+ target_msg_id=event.message_id,
79
+ set=True
80
+ )
81
+ except Exception as e:
82
+ logger.warning(f"添加表情失败: {e}")
83
+
84
+ # ----------------------------------------------------------------
85
+ # 执行撤回
86
+ # ----------------------------------------------------------------
87
+ try:
88
+ await bot.delete_msg(message_id=reply.message_id)
89
+ # ----------------------------------------------------------------
90
+ # 撤回成功 将表情改为喝彩
91
+ # ----------------------------------------------------------------
92
+ try:
93
+ await message_reaction(
94
+ event=event,
95
+ reaction="/hec",
96
+ target_msg_id=event.message_id,
97
+ set=True
98
+ )
99
+ except Exception as e:
100
+ logger.warning(f"修改表情失败: {e}")
101
+ await recall.finish("撤回成功!")
102
+ except Exception as e:
103
+ error_msg = str(e)
104
+ if "时间" in error_msg or "超时" in error_msg or "过期" in error_msg:
105
+ await recall.finish("消息已超过可撤回时间,无法撤回")
106
+ else:
107
+ logger.error(f"撤回失败: {e}")
108
+ await recall.finish(f"撤回失败:{error_msg}")
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: nonebot-plugin-helper-recall
3
+ Version: 0.1.0
4
+ Summary: 帮助普通群员撤回自己超时无法撤回的消息
5
+ Author-email: Wojusensei <3442006415@qq.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Wojusensei/nonebot-plugin-helper-recall
8
+ Classifier: Programming Language :: Python :: 3
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: nonebot2>=2.3.0
12
+ Requires-Dist: nonebot-adapter-onebot>=2.0.0
13
+ Requires-Dist: nonebot-plugin-alconna>=0.3.0
14
+ Requires-Dist: nonebot-plugin-localstore>=0.5.0
15
+
16
+ # nonebot-plugin-helper-recall
17
+
18
+ ✨ 帮撤回插件 ✨
19
+
20
+ 帮助普通群员撤回自己因超时无法撤回的消息,需要bot被群主授予管理员权限(想给bot群主我也没意见(bushi))
21
+
22
+ ## 功能
23
+
24
+ - 引用自己发送的消息,发送 `/撤回` 指令
25
+ - Bot 尝试撤回该消息
26
+ - 撤回成功后在指令消息上添加 🎉 表情
27
+
28
+ ## 安装(指令二选一,无区别)
29
+
30
+ ```bash
31
+ nb plugin install nonebot-plugin-helper-recall
32
+ pip install nonebot-plugin-helper-recall
33
+ ```
34
+
35
+ ## 使用
36
+
37
+ 1. 确保 Bot 是群管理员
38
+ 2. 群员引用自己发送的任意消息(包括超时的)
39
+ 3. 在同一条消息中发送 `/撤回`
40
+ 4. Bot 会撤回那条被引用的消息
41
+
42
+ ## 注意事项
43
+
44
+ - 仅支持撤回自己的消息
45
+ - 如果消息已超过 QQ 可撤回时间,会提示失败
46
+ - 需要 Bot 有管理员权限
47
+
48
+ ## 配置
49
+
50
+ 无需配置,即装即用
51
+
52
+ ## 开源协议
53
+
54
+ MIT
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ nonebot_plugin_helper_recall/__init__.py
4
+ nonebot_plugin_helper_recall/config.py
5
+ nonebot_plugin_helper_recall.egg-info/PKG-INFO
6
+ nonebot_plugin_helper_recall.egg-info/SOURCES.txt
7
+ nonebot_plugin_helper_recall.egg-info/dependency_links.txt
8
+ nonebot_plugin_helper_recall.egg-info/requires.txt
9
+ nonebot_plugin_helper_recall.egg-info/top_level.txt
@@ -0,0 +1,4 @@
1
+ nonebot2>=2.3.0
2
+ nonebot-adapter-onebot>=2.0.0
3
+ nonebot-plugin-alconna>=0.3.0
4
+ nonebot-plugin-localstore>=0.5.0
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nonebot-plugin-helper-recall"
7
+ version = "0.1.0"
8
+ description = "帮助普通群员撤回自己超时无法撤回的消息"
9
+ authors = [{name = "Wojusensei", email = "3442006415@qq.com"}]
10
+ readme = "README.md"
11
+ license = {text = "MIT"}
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ ]
15
+ dependencies = [
16
+ "nonebot2>=2.3.0",
17
+ "nonebot-adapter-onebot>=2.0.0",
18
+ "nonebot-plugin-alconna>=0.3.0",
19
+ "nonebot-plugin-localstore>=0.5.0",
20
+ ]
21
+ requires-python = ">=3.9"
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/Wojusensei/nonebot-plugin-helper-recall"
25
+
26
+ [tool.setuptools]
27
+ packages = ["nonebot_plugin_helper_recall"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+