koishi-plugin-mute-repeater 0.0.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 idranme
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/lib/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { Context, Schema } from 'koishi';
2
+ export declare const name = "mute-repeater";
3
+ export interface Config {
4
+ minTimes: number;
5
+ muteDuration: number;
6
+ maxDurationMultiplier: number;
7
+ }
8
+ export declare const Config: Schema<Config>;
9
+ export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js ADDED
@@ -0,0 +1,90 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __commonJS = (cb, mod) => function __require() {
7
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
8
+ };
9
+ var __export = (target, all) => {
10
+ for (var name2 in all)
11
+ __defProp(target, name2, { get: all[name2], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+
23
+ // src/locales/zh-CN.yml
24
+ var require_zh_CN = __commonJS({
25
+ "src/locales/zh-CN.yml"(exports2, module2) {
26
+ module2.exports = { muteNotice: "还复读?给你禁言个{duration}分钟!" };
27
+ }
28
+ });
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Config: () => Config,
34
+ apply: () => apply,
35
+ name: () => name
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+ var import_koishi = require("koishi");
39
+ var name = "mute-repeater";
40
+ var Config = import_koishi.Schema.object({
41
+ minTimes: import_koishi.Schema.natural().min(1).default(5).description("最少重复次数"),
42
+ muteDuration: import_koishi.Schema.natural().min(1).default(60).description("禁言时长,单位为分钟"),
43
+ maxDurationMultiplier: import_koishi.Schema.natural().min(1).default(8).description("最大禁言时长倍率")
44
+ });
45
+ function getRandomInt(min, max) {
46
+ return Math.floor(Math.random() * (max - min + 1)) + min;
47
+ }
48
+ __name(getRandomInt, "getRandomInt");
49
+ function apply(ctx, config) {
50
+ ctx.i18n.define("zh-CN", require_zh_CN());
51
+ const states = {};
52
+ function getState(cid) {
53
+ return states[cid] || (states[cid] = {
54
+ content: "",
55
+ times: 0
56
+ });
57
+ }
58
+ __name(getState, "getState");
59
+ ctx.guild().on("message-created", async (session) => {
60
+ const state = getState(session.cid);
61
+ if (session.content === state.content) {
62
+ state.times += 1;
63
+ if (state.times >= config.minTimes) {
64
+ state.times = 0;
65
+ const multiplier = getRandomInt(1, config.maxDurationMultiplier);
66
+ await session.bot.muteGuildMember(session.guildId, session.userId, config.muteDuration * 60 * 1e3 * multiplier);
67
+ await session.send(session.text("muteNotice", { duration: config.muteDuration * multiplier }));
68
+ }
69
+ } else {
70
+ state.content = session.content;
71
+ state.times = 0;
72
+ }
73
+ });
74
+ ctx.guild().on("send", (session) => {
75
+ const state = getState(session.cid);
76
+ if (session.content === state.content) {
77
+ state.times += 1;
78
+ } else {
79
+ state.content = session.content;
80
+ state.times = 0;
81
+ }
82
+ });
83
+ }
84
+ __name(apply, "apply");
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ Config,
88
+ apply,
89
+ name
90
+ });
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "koishi-plugin-mute-repeater",
3
+ "description": "Mute Repeater",
4
+ "version": "0.0.1",
5
+ "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
+ "files": [
8
+ "lib",
9
+ "dist"
10
+ ],
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "chatbot",
14
+ "koishi",
15
+ "plugin",
16
+ "mute",
17
+ "repeater",
18
+ "anti",
19
+ "repeat"
20
+ ],
21
+ "peerDependencies": {
22
+ "koishi": "^4.17.7"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/idranme/koishi-plugin-mute-repeater.git"
27
+ },
28
+ "koishi": {
29
+ "description": {
30
+ "zh": "禁言复读",
31
+ "en": "Mute Repeater"
32
+ },
33
+ "browser": true
34
+ }
35
+ }
package/readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # koishi-plugin-mute-repeater
2
+
3
+ [![npm](https://img.shields.io/npm/v/koishi-plugin-mute-repeater?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-mute-repeater)
4
+
5
+ Mute Repeater