koishi-plugin-xxpk-1 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/lib/index.d.ts +9 -0
- package/lib/index.js +71 -0
- package/package.json +22 -0
- package/readme.md +5 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Context, Schema } from 'koishi';
|
|
2
|
+
export declare const name = "poke-reply";
|
|
3
|
+
export interface Config {
|
|
4
|
+
replies: string[];
|
|
5
|
+
pokeBack: boolean;
|
|
6
|
+
pokeProb: 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,71 @@
|
|
|
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 __export = (target, all) => {
|
|
7
|
+
for (var name2 in all)
|
|
8
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Config: () => Config,
|
|
24
|
+
apply: () => apply,
|
|
25
|
+
name: () => name
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
var import_koishi = require("koishi");
|
|
29
|
+
var name = "poke-reply";
|
|
30
|
+
var Config = import_koishi.Schema.object({
|
|
31
|
+
replies: import_koishi.Schema.array(String).description("自定义回复文本数组").default(["不要戳我!", "你想干什么?", "再戳我就生气了!", "你有什么事吗?", "你好无聊啊。", "你是不是喜欢我?"]),
|
|
32
|
+
pokeBack: import_koishi.Schema.boolean().description("是否启用戳回去功能").default(true),
|
|
33
|
+
pokeProb: import_koishi.Schema.number().description("戳回去概率").default(0.2)
|
|
34
|
+
});
|
|
35
|
+
function apply(ctx, config) {
|
|
36
|
+
const logger = ctx.logger("poke-reply");
|
|
37
|
+
ctx.on("notice:notify", async (rawSession) => {
|
|
38
|
+
const s = rawSession;
|
|
39
|
+
if (s.noticeType !== "notify" || s.subType !== "poke") return;
|
|
40
|
+
if (s.targetId !== s.selfId) return;
|
|
41
|
+
logger.info(`收到戳一戳 | 用户:${s.userId}`);
|
|
42
|
+
const reply = config.replies[Math.floor(Math.random() * config.replies.length)];
|
|
43
|
+
if (config.pokeBack && Math.random() < config.pokeProb) {
|
|
44
|
+
try {
|
|
45
|
+
if (s.guildId) {
|
|
46
|
+
await s.bot.sendAction("group_poke", {
|
|
47
|
+
group_id: s.guildId,
|
|
48
|
+
user_id: s.userId
|
|
49
|
+
});
|
|
50
|
+
} else {
|
|
51
|
+
await s.bot.sendAction("friend_poke", {
|
|
52
|
+
user_id: s.userId
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
logger.info(`成功戳回用户:${s.userId}`);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
logger.error("戳回失败:", e);
|
|
58
|
+
await s.send(reply);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
await s.send(reply);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
__name(apply, "apply");
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
Config,
|
|
69
|
+
apply,
|
|
70
|
+
name
|
|
71
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koishi-plugin-xxpk-1",
|
|
3
|
+
"description": "[开发中]",
|
|
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
|
+
"scripts": {},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"chatbot",
|
|
15
|
+
"koishi",
|
|
16
|
+
"plugin"
|
|
17
|
+
],
|
|
18
|
+
"devDependencies": {},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"koishi": "^4.18.7"
|
|
21
|
+
}
|
|
22
|
+
}
|