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-nl-permission

v0.0.1

Published

自用

Readme

koishi-plugin-nl-permission

npm

群组和私聊白名单管理插件,支持拦截非白名单消息。

功能特性

  • 群组白名单:只在白名单群组中响应消息
  • 私聊白名单:支持私聊白名单或完全禁止私聊
  • 智能拦截:使用 before-send 中间件拦截非白名单消息
  • 被 @ 提示:在非白名单群聊中被 @ 时可发送自定义提示
  • 管理员权限:支持管理员绕过白名单限制
  • 数据持久化:使用数据库存储白名单,重启后不丢失
  • 多平台支持:支持不同平台的独立白名单管理

配置项

| 配置项 | 类型 | 默认值 | 说明 | |--------|------|--------|------| | allowPrivate | boolean | false | 是否允许所有私聊(关闭时只允许白名单用户) | | privateReply | string | "抱歉,暂不支持私聊功能。" | 私聊被拒绝时的回复消息 | | replyWhenMentioned | boolean | true | 在非白名单群聊中被 @ 时是否回复 | | mentionReply | string | "抱歉,本群未开启服务。如需使用请联系管理员。" | 被 @ 时的回复消息 | | adminUsers | string[] | [] | 管理员用户ID列表 | | bypassAdmin | boolean | true | 管理员是否绕过白名单限制 |

使用命令

管理命令(仅管理员)

  • nlp.群白名单 <群组ID> [备注] - 添加群组到白名单
  • nlp.私聊白名单 <用户ID> [备注] - 添加用户到私聊白名单
  • nlp.这里 [备注] - 快速添加当前群组到白名单
  • nlp.移除群 <群组ID> - 从白名单移除群组
  • nlp.移除私聊 <用户ID> - 从私聊白名单移除用户
  • nlp.列表 - 查看所有白名单
  • nlp.状态 - 查看当前环境信息

命令别名

  • nlp.addguild = nlp.群白名单
  • nlp.addprivate = nlp.私聊白名单
  • nlp.here = nlp.这里
  • nlp.removeguild = nlp.移除群
  • nlp.removeprivate = nlp.移除私聊
  • nlp.list = nlp.列表
  • nlp.status = nlp.状态

使用场景

场景 1:只在特定群组中提供服务

  1. 在配置中添加管理员用户ID
  2. 在需要开启服务的群组中发送 nlp.这里
  3. 机器人将只在白名单群组中响应消息

场景 2:禁止私聊

  1. 保持 allowPrivatefalse(默认)
  2. 非白名单用户私聊时会收到拒绝消息
  3. 如需允许特定用户私聊,使用 nlp.私聊白名单 <用户ID>

场景 3:被 @ 时提示

  1. 保持 replyWhenMentionedtrue(默认)
  2. 在非白名单群聊中被 @ 时,机器人会发送提示消息
  3. 可自定义 mentionReply 消息内容

工作原理

插件使用 Koishi 的 before-send 中间件拦截消息:

  1. 检查用户是否是管理员(如果启用绕过)
  2. 私聊环境:检查私聊白名单或 allowPrivate 配置
  3. 群聊环境:检查群组白名单
  4. 非白名单群聊被 @:发送提示消息
  5. 其他情况:清空 session.elements 拦截消息

注意事项

  • 需要 Koishi 数据库服务支持
  • 管理员用户ID需要在配置中手动添加
  • 白名单按平台独立管理(OneBot、Discord 等)
  • 拦截的是机器人的发送消息,不影响接收消息

License

MIT