Skip to main content

nonebot-plugin-attack

一个用于“定向攻击”的 NoneBot2 娱乐插件:它只反复操作目标用户消息上的 reaction, 不会让 Bot 连续向群聊发送新消息,因此不会刷到其他群友的聊天界面。

回复一条消息发送 /attack 后,Bot 会持续为目标消息添加、移除并重新添加指定 reaction;发送停止命令即可结束。-target 模式会追踪被回复用户在当前会话内随后发送的消息,并同时对其最新若干条消息持续执行 reaction。

功能

  • 对被回复消息定向地持续添加/移除 reaction,不发送群聊刷屏消息。
  • 自定义持续时间,支持秒数、s 和“秒”后缀。
  • -target 模式追踪目标用户后续消息。
  • 每个会话最多运行一个 attack,互不影响。
  • 可配置每轮次数、轮次间隔、reaction ID 和最长持续时间。
  • 插件卸载或 Bot 关闭时自动取消全部后台任务。
  • 命令成功和失败默认通过 reaction 反馈,减少文字刷屏。

安装

使用 NB-CLI:

nb plugin install nonebot-plugin-attack

或使用包管理器:

pip install nonebot-plugin-attack

使用

以下命令需要回复一条消息:

/attack
/attack -time 30
/attack -time 30s
/attack -target
/attack -time 30 -target

其他命令:

/attack help     查看插件帮助
/stopattack      停止当前会话的 attack
/stop            兼容的简短停止命令

-target 会识别被回复消息的发送者,并对该用户随后发出的最新消息执行 attack。默认最多同时保留 5 条目标消息;超过后会停止最早的一条。

配置

所有配置均为可选,插件可以零配置加载。

# 每轮 reaction 操作后的等待时间,单位为秒
ATTACK_LOOP_INTERVAL=1.0

# 每轮执行多少次“添加后移除”,随后再保留一次 reaction
ATTACK_REACTIONS_PER_ROUND=5

# 对目标消息使用的 reaction ID
ATTACK_REACTION_EMOJI=38

# 命令成功/失败反馈 reaction ID
ATTACK_COMMAND_SUCCESS_EMOJI=144
ATTACK_COMMAND_FAIL_EMOJI=129

# 默认及最大持续时间,单位为秒
ATTACK_DEFAULT_SECONDS=10.0
ATTACK_MAX_SECONDS=360.0

# -target 模式同时 attack 的最新消息数量
ATTACK_TARGET_MAX_MESSAGES=5

行为与风险说明

本插件的核心功能就是高频调用平台的 reaction 接口。实际效果、可用 reaction ID、频率限制和风控规则由适配器及机器人协议端决定。过高的轮次次数、过短的间隔或过长的持续时间可能导致接口限流、账号风控或消息平台拒绝请求。

插件会捕获单次 reaction 调用失败并记录日志,不会因此让后台任务永久崩溃。请根据所用平台合理调整配置,并遵守平台规则。

兼容性

插件直接使用 OneBot V11 的 reaction 扩展 API,不依赖 nonebot-plugin-alconna。 目前支持 Lagrange.OneBot、NapCat、LLOneBot 和 ws-plugin;不同协议端的 reaction API 并未纳入 OneBot V11 标准,因此更换协议端后请先确认版本兼容性。-target 模式在无法从 回复事件取得用户 ID 时,会尝试调用 get_msg 查询原消息。

开发

uv sync --group dev --group pydantic-v2
uv run ruff check .
uv run ruff format --check .
uv run basedpyright
uv run pytest
uv build

兼容性测试可分别使用 uv sync --group dev --group pydantic-v1 和 uv sync --group dev --group pydantic-v2 创建环境。

许可证

MIT

Metadata

Release files for nonebot-plugin-attack 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-attack 0.1.1
File Size Uploaded
nonebot_plugin_attack-0.1.1.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-attack 0.1.1
File Interpreter ABI Platform
nonebot_plugin_attack-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.4 kB

Release files / nonebot_plugin_attack-0.1.1.tar.gz

Download URL nonebot_plugin_attack-0.1.1.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0efb27cb5ba25dadec0c508b709ddbb967d5a0fca821a2dc20db2b9c16ae8e8f
BLAKE2b-256 checksum
How to use checksums
072656bf48ee9dddc828d9b41de1377941953bdd10eddd7794cceec363ed2691
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.

Transparency log

Release files / nonebot_plugin_attack-0.1.1-py3-none-any.whl

Download URL nonebot_plugin_attack-0.1.1-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ee2c68617fc659f95d698436fbbdd4ead91e506c1b40ba0e94e54e77490b74c
BLAKE2b-256 checksum
How to use checksums
f5a488276956b30eb68ec4a656c747ccd1b9c1e0dc9ef329e8cd8a64df1a004d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page