npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

koishi-plugin-limit-rate

v1.1.4

Published

限制指令和中间件的调用频率和每日调用次数

Readme

koishi-plugin-rate-limit

npm

限制指令的调用频率和每日调用次数。

✨ 功能特性

🎯 指令中心:专注于 指令 (Command) 的频率与次数限制。 🔧 灵活配置:可对每个指令单独设置冷却时间(minInterval)和每日使用次数上限(maxDayUsage)。 🌐 范围控制:支持以 用户 (user)频道 (channel)平台 (platform) 为单位,精细化管理每个指令的限制范围。 💬 智能提示:可配置在触发限流时,是否向用户发送人性化的提示信息。 ⚖️ 例外规则:通过强大的规则列表,实现对特定用户或频道的豁免(白名单)和禁用(黑名单)功能。

⚙️ 插件配置

插件的配置分为两个主要部分:全局设置单个指令的设置

1. 全局设置

这些是本插件的核心设置,用于控制插件的全局行为。

sendHint: (布尔值) 当用户操作被限流时,是否发送提示信息。

  • false (默认): 静默处理,不发送任何消息。
  • true: 发送“操作过于频繁...”或“使用已达上限...”等提示。

commandRules: (数组) 例外规则列表。用于将特定用户或频道设置为“豁免”或“限制”。默认情况下,所有用户都遵循每个指令的独立配置。

  • type: (user | channel) 规则匹配的类型。
    • user: 按用户 ID 匹配。
    • channel: 按频道 ID 匹配。
  • content: (字符串) 要匹配的具体 ID(用户 ID 或频道 ID)。
  • action: (block | ignore) 对匹配目标执行的行为。
    • ignore: 豁免。该用户/频道调用任何指令时,都不会受到此插件的任何频率或次数限制。
    • block: 限制。该用户/频道不能调用任何受此插件管理的指令。

2. 单个指令的设置

要对某个特定的指令进行频率或次数限制,你需要进入该指令自身的配置页面。在 Koishi 控制台中,通常路径是 插件 -> <指令所在插件> -> Command -> <目标指令>

scope: (user | channel | platform) 该指令频率限制的生效范围。

  • user: 针对单个用户进行限制。
  • channel: (默认) 针对单个频道进行限制。
  • platform: 整个平台(如 QQ、Discord)共享同一个限制计数。

maxDayUsage: (数字) 该指令的每日最大使用次数。设置为 0 (默认) 则不限制。

minInterval: (数字) 该指令的最小调用间隔(单位:秒),即冷却时间 (Cooldown)。设置为 0 (默认) 则不限制。


示例

示例 1:豁免管理员调用所有指令

假设你想限制普通用户,但豁免管理员(QQ号:12345678),可以这样配置:

  1. 在本插件的 commandRules (例外列表) 中添加一条规则:
    • type: user (按用户ID匹配)
    • content: 12345678 (管理员的 QQ 号)
    • action: ignore (豁免)

示例 2:让 echo 指令每用户每 10 秒只能用一次

  1. 前往 echo 指令自身的配置页面。
  2. 进行如下设置:
    • scope: user (限制范围设为“用户”)
    • maxDayUsage: 0 (不限制每日总次数)
    • minInterval: 10 (设置 10 秒冷却时间)