Skip to main content

nonebot-plugin-attack

一个明确用于“刷消息 reaction”的 NoneBot2 娱乐插件。

回复一条消息发送 /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 调用失败并记录日志,不会因此让后台任务永久崩溃。请根据所用平台合理调整配置,并遵守平台规则。

兼容性

插件通过 nonebot-plugin-alconna 的 UniSeg reaction API 工作,支持范围继承自该插件;具体适配器能否使用 reaction 取决于其导出实现。-target 模式在无法从回复事件取得用户 ID 时,会尝试调用适配器的 get_msg API 查询原消息。

开发

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.0

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.0
File Size Uploaded
nonebot_plugin_attack-0.1.0.tar.gz 7.3 kB Details

Built distribution (wheel)

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

Total release size: 15.6 kB

Release files / nonebot_plugin_attack-0.1.0.tar.gz

Download URL nonebot_plugin_attack-0.1.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bed3adbfb38407f15da1637d3861c83e3613d5fc535612e64733b3a8eb8d3fbc
BLAKE2b-256 checksum
How to use checksums
f512a0a69b1661365bc3e1c22bd8c38d4a25277f5113b873a8cf2690bdae5086
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.0-py3-none-any.whl

Download URL nonebot_plugin_attack-0.1.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
313030617e2a496b82cd0933f9d8ad1e8bf3ec53bfc6fc9c91fb0b90d3badc2c
BLAKE2b-256 checksum
How to use checksums
cd81b2378da08a131286bca6add4df36f8d57d7245cd516e7c7bbe8fe6ac3d7e
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

0.1.1

2 release files

This release

0.1.0 This release

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