koishi-plugin-lolbaninfo 1.0.0

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/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{resolveComponent as r,createBlock as a,openBlock as s,withCtx as _,createTextVNode as p}from"vue";const l=(t,e)=>{const o=t.__vccOpts||t;for(const[n,c]of e)o[n]=c;return o},u={};function f(t,e){const o=r("k-layout");return s(),a(o,null,{default:_(()=>[...e[0]||(e[0]=[p("扩展内容",-1)])]),_:1})}const m=l(u,[["render",f]]),x=t=>{t.page({name:"扩展页面",path:"/custom-page",component:m})};export{x as default};
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+
package/lib/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Context, Schema } from 'koishi';
2
+ export declare const name = "lolbaninfo";
3
+ export interface Config {
4
+ apiUrl: string;
5
+ apiToken: string;
6
+ retryTimes: number;
7
+ retryDelay: number;
8
+ maxLogCount: number;
9
+ }
10
+ export declare const usage = "\n# \u26A0\uFE0F LOL\u5C01\u53F7\u67E5\u8BE2\u63D2\u4EF6 \u26A0\uFE0F\n\u65E0\u9700\u5BC6\u7801\uFF0C\u76F4\u63A5\u6839\u636EQQ\u53F7\u67E5\u8BE2\u8D26\u53F7\u5C01\u7981\u72B6\u6001\u4E0E\u8BE6\u7EC6\u4FE1\u606F\n";
11
+ export declare const Config: Schema<Config>;
12
+ export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js ADDED
@@ -0,0 +1,146 @@
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
+ usage: () => usage
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+ var import_koishi = require("koishi");
30
+ var import_utils = require("@koishijs/utils");
31
+ var name = "lolbaninfo";
32
+ var usage = `
33
+ # ⚠️ LOL封号查询插件 ⚠️
34
+ 无需密码,直接根据QQ号查询账号封禁状态与详细信息
35
+ `;
36
+ var Config = import_koishi.Schema.object({
37
+ apiUrl: import_koishi.Schema.string().description("目标网站的API接口地址(固定为文档地址)").default("https://yun.4png.com/api/query.html"),
38
+ apiToken: import_koishi.Schema.string().description("网站API的访问Token(注册即可获得)").required(),
39
+ retryTimes: import_koishi.Schema.number().description("请求失败时的最大重试次数").default(2).min(0).max(5),
40
+ retryDelay: import_koishi.Schema.number().description("每次重试的间隔时间(毫秒)").default(1e3).min(500).max(5e3),
41
+ maxLogCount: import_koishi.Schema.number().description("日志自动清理阈值(最大存储条数)").default(100).min(20).max(500)
42
+ });
43
+ var logCache = [];
44
+ function addLogAndClean(logger, content, maxCount) {
45
+ const formattedLog = `[${(/* @__PURE__ */ new Date()).toLocaleString()}] ${content}`;
46
+ logCache.push(formattedLog);
47
+ if (logCache.length > maxCount) {
48
+ const deleteCount = logCache.length - maxCount;
49
+ logCache.splice(0, deleteCount);
50
+ logger.info(`[日志清理] 已删除${deleteCount}条旧日志,当前保留${logCache.length}条`);
51
+ }
52
+ }
53
+ __name(addLogAndClean, "addLogAndClean");
54
+ async function requestWithRetry(ctx, config, qq, logger) {
55
+ let attempt = 0;
56
+ while (attempt <= config.retryTimes) {
57
+ try {
58
+ const requestLog = `[第${attempt + 1}次请求] 开始查询QQ:${qq},目标API:${config.apiUrl}`;
59
+ addLogAndClean(logger, requestLog, config.maxLogCount);
60
+ logger.info(requestLog);
61
+ const response = await ctx.http.get(config.apiUrl, {
62
+ params: {
63
+ qq,
64
+ token: config.apiToken
65
+ },
66
+ // 强制解析JSON,避免返回文本格式
67
+ responseType: "json"
68
+ });
69
+ const successLog = `[第${attempt + 1}次请求] 查询成功,返回状态码:200`;
70
+ addLogAndClean(logger, successLog, config.maxLogCount);
71
+ logger.success(successLog);
72
+ return response;
73
+ } catch (error) {
74
+ attempt++;
75
+ const status = error.response?.status || "未知状态";
76
+ const failLog = `[第${attempt}次请求] 失败,状态码:${status},错误信息:${error.message}`;
77
+ addLogAndClean(logger, failLog, config.maxLogCount);
78
+ logger.warn(failLog);
79
+ const isRetryable = [400, 403].includes(status);
80
+ if (!isRetryable || attempt > config.retryTimes) {
81
+ const endLog = `[请求终止] 非重试错误或已达最大重试次数(${config.retryTimes}次)`;
82
+ addLogAndClean(logger, endLog, config.maxLogCount);
83
+ logger.error(endLog);
84
+ throw error;
85
+ }
86
+ const retryLog = `[准备重试] 间隔${config.retryDelay}ms后进行第${attempt}次重试`;
87
+ addLogAndClean(logger, retryLog, config.maxLogCount);
88
+ logger.info(retryLog);
89
+ await (0, import_utils.sleep)(config.retryDelay);
90
+ }
91
+ }
92
+ throw new Error("达到最大重试次数,请求失败");
93
+ }
94
+ __name(requestWithRetry, "requestWithRetry");
95
+ function isValidQQ(qq) {
96
+ return /^\d{5,13}$/.test(qq);
97
+ }
98
+ __name(isValidQQ, "isValidQQ");
99
+ function apply(ctx, config) {
100
+ const logger = ctx.logger(name);
101
+ ctx.command("查封号 <qq号>", "查询QQ号封号状态").action(async (_, qq) => {
102
+ if (!isValidQQ(qq)) {
103
+ const errMsg = `QQ号格式错误:${qq}(需5-13位数字)`;
104
+ addLogAndClean(logger, errMsg, config.maxLogCount);
105
+ logger.warn(errMsg);
106
+ return `❌ ${errMsg}`;
107
+ }
108
+ try {
109
+ const result = await requestWithRetry(ctx, config, qq, logger);
110
+ const msg = result.msg || "无返回信息";
111
+ switch (result.code) {
112
+ case 200:
113
+ const banInfo = result.data?.banmsg || "无详细封禁信息";
114
+ const successResLog = `[查询结果] QQ${qq}:${msg} → ${banInfo}`;
115
+ addLogAndClean(logger, successResLog, config.maxLogCount);
116
+ logger.success(successResLog);
117
+ return `✅ 查询成功:${msg}
118
+ 📝 详细信息:${banInfo}`;
119
+ case 400:
120
+ const warnResLog = `[查询结果] QQ${qq} 400错误:${msg}`;
121
+ addLogAndClean(logger, warnResLog, config.maxLogCount);
122
+ logger.warn(warnResLog);
123
+ return `❌ 查询失败 [错误码400]:${msg}(参数缺失,请检查配置)`;
124
+ default:
125
+ const infoResLog = `[查询结果] QQ${qq} 错误码${result.code}:${msg}`;
126
+ addLogAndClean(logger, infoResLog, config.maxLogCount);
127
+ logger.info(infoResLog);
128
+ return `❌ 查询失败 [错误码${result.code}]:${msg}`;
129
+ }
130
+ } catch (error) {
131
+ const errMsg = error.message || "未知错误";
132
+ const errorLog = `[接口调用出错] QQ${qq}:${errMsg}`;
133
+ addLogAndClean(logger, errorLog, config.maxLogCount);
134
+ logger.error(errorLog);
135
+ return `⚠️ 接口调用出错:${errMsg}`;
136
+ }
137
+ });
138
+ }
139
+ __name(apply, "apply");
140
+ // Annotate the CommonJS export names for ESM import in node:
141
+ 0 && (module.exports = {
142
+ Config,
143
+ apply,
144
+ name,
145
+ usage
146
+ });
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "koishi-plugin-lolbaninfo",
3
+ "description": "LOL封号查询插件",
4
+ "version": "1.0.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/lenksen/lolbaninfo.git"
8
+ },
9
+ "main": "lib/index.js",
10
+ "typings": "lib/index.d.ts",
11
+ "files": [
12
+ "lib",
13
+ "dist"
14
+ ],
15
+ "license": "MIT",
16
+ "homepage": "https://github.com/lenksen/lolbaninfo",
17
+ "keywords": [
18
+ "chatbot",
19
+ "koishi",
20
+ "封号查询",
21
+ "英雄联盟",
22
+ "plugin"
23
+ ],
24
+ "devDependencies": {
25
+ "@koishijs/client": "^5.30.4"
26
+ },
27
+ "peerDependencies": {
28
+ "@koishijs/plugin-console": "^5.30.4",
29
+ "koishi": "^4.18.7"
30
+ },
31
+ "dependencies": {
32
+ "@koishijs/utils": "^7.3.2"
33
+ }
34
+ }
package/readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # koishi-plugin-lolbaninfo
2
+
3
+ [![npm](https://img.shields.io/npm/v/koishi-plugin-lolbaninfo?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-lolbaninfo)
4
+
5
+ LOL封号查询插件