koishi-plugin-gl-bot 0.0.13 → 0.0.15

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.
Files changed (66) hide show
  1. package/lib/ali/client.d.ts +17 -0
  2. package/lib/ali/client.js +151 -0
  3. package/lib/ali/index.d.ts +12 -0
  4. package/lib/ali/index.js +64 -0
  5. package/lib/ali/local.domain.d.ts +19 -0
  6. package/lib/ali/local.domain.js +57 -0
  7. package/lib/ali/type.d.ts +23 -0
  8. package/lib/ali/type.js +27 -0
  9. package/lib/gl/commands/base.d.ts +20 -0
  10. package/lib/gl/commands/base.js +33 -0
  11. package/lib/gl/commands/index.d.ts +1 -0
  12. package/lib/gl/commands/index.js +37 -0
  13. package/lib/gl/commands/register.d.ts +6 -0
  14. package/lib/gl/commands/register.js +12 -0
  15. package/lib/gl/config.d.ts +21 -0
  16. package/lib/gl/config.js +19 -0
  17. package/lib/gl/index.d.ts +22 -1
  18. package/lib/gl/index.js +32 -2
  19. package/lib/gl/queqiao.adapter.d.ts +2 -2
  20. package/lib/gl/queqiao.adapter.js +26 -24
  21. package/lib/mcsManager/api.d.ts +2 -0
  22. package/lib/mcsManager/api.js +31 -14
  23. package/lib/mcsManager/bot.d.ts +0 -1
  24. package/lib/mcsManager/bot.js +56 -11
  25. package/lib/mcsManager/commands/ark/create.d.ts +1 -1
  26. package/lib/mcsManager/commands/ark/create.js +1 -2
  27. package/lib/mcsManager/commands/ark/list.d.ts +1 -1
  28. package/lib/mcsManager/commands/ark/list.js +1 -2
  29. package/lib/mcsManager/commands/ark/restart.d.ts +1 -1
  30. package/lib/mcsManager/commands/ark/restart.js +1 -2
  31. package/lib/mcsManager/commands/ark/start.d.ts +1 -1
  32. package/lib/mcsManager/commands/ark/start.js +1 -2
  33. package/lib/mcsManager/commands/ark/stop.d.ts +1 -1
  34. package/lib/mcsManager/commands/ark/stop.js +1 -2
  35. package/lib/mcsManager/commands/index.d.ts +1 -1
  36. package/lib/mcsManager/commands/index.js +1 -1
  37. package/lib/mcsManager/commands/mc/create.d.ts +1 -1
  38. package/lib/mcsManager/commands/mc/create.js +1 -2
  39. package/lib/mcsManager/commands/mc/health.d.ts +3 -3
  40. package/lib/mcsManager/commands/mc/health.js +1 -2
  41. package/lib/mcsManager/commands/mc/list.d.ts +1 -1
  42. package/lib/mcsManager/commands/mc/list.js +2 -2
  43. package/lib/mcsManager/commands/mc/online.d.ts +4 -4
  44. package/lib/mcsManager/commands/mc/online.js +1 -3
  45. package/lib/mcsManager/commands/mc/restart.d.ts +1 -1
  46. package/lib/mcsManager/commands/mc/restart.js +1 -2
  47. package/lib/mcsManager/commands/mc/start.d.ts +1 -1
  48. package/lib/mcsManager/commands/mc/start.js +1 -2
  49. package/lib/mcsManager/commands/mc/stop.d.ts +1 -1
  50. package/lib/mcsManager/commands/mc/stop.js +1 -2
  51. package/lib/mcsManager/index.d.ts +6 -3
  52. package/lib/mcsManager/index.js +6 -1
  53. package/lib/mcsManager/instance.d.ts +7 -1
  54. package/lib/mcsManager/instance.js +51 -1
  55. package/lib/mcsManager/panel.d.ts +9 -4
  56. package/lib/mcsManager/panel.js +53 -8
  57. package/lib/mcsManager/type.d.ts +34 -2
  58. package/lib/queQiao/index.d.ts +5 -5
  59. package/lib/queQiao/index.js +7 -7
  60. package/lib/utils/axios.d.ts +1 -0
  61. package/lib/utils/axios.js +31 -0
  62. package/lib/utils/cat_enc.d.ts +4 -0
  63. package/lib/utils/cat_enc.js +8641 -0
  64. package/lib/utils/huawei.d.ts +142 -0
  65. package/lib/utils/huawei.js +233 -0
  66. package/package.json +8 -2
@@ -0,0 +1,17 @@
1
+ import * as $Alidns20150109 from '@alicloud/alidns20150109';
2
+ import { DomainRecordsExplorerType } from './type';
3
+ export declare class AliYun {
4
+ readonly accessKeyId?: string;
5
+ readonly accessKeySecret?: string;
6
+ constructor(accessKeyId?: string, accessKeySecret?: string);
7
+ /** 获取 域名列表 */
8
+ fetchDomainList(): Promise<$Alidns20150109.DescribeDomainsResponseBody>;
9
+ /** 获取 解析记录 列表 */
10
+ fetchDomainRecords(domainName: string): Promise<$Alidns20150109.DescribeDomainRecordsResponseBody | null>;
11
+ /** 定位 子域名解析记录 */
12
+ findSubDomainRecords(domainName: string, RR: string): Promise<$Alidns20150109.DescribeDomainRecordsResponseBodyDomainRecordsRecord | null>;
13
+ /** 更新 解析记录 备注 */
14
+ updateDomainRecordRemarkRequest(recordId: string, remark: string): Promise<$Alidns20150109.UpdateDomainRecordRemarkResponseBody | null>;
15
+ /** 更新 子域名 解析记录 */
16
+ updateDomainRecord(domainName: string, RR: string, type: DomainRecordsExplorerType, value: string): Promise<boolean | $Alidns20150109.UpdateDomainRecordResponseBody>;
17
+ }
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AliYun = void 0;
40
+ const $Alidns20150109 = __importStar(require("@alicloud/alidns20150109"));
41
+ const $Util = __importStar(require("@alicloud/tea-util"));
42
+ const dayjs_1 = __importDefault(require("dayjs"));
43
+ const koishi_1 = require("koishi");
44
+ const _1 = require(".");
45
+ const constants_1 = require("../constants");
46
+ const logger = new koishi_1.Logger('GL');
47
+ class AliYun {
48
+ constructor(accessKeyId, accessKeySecret) {
49
+ this.accessKeyId = accessKeyId;
50
+ this.accessKeySecret = accessKeySecret;
51
+ }
52
+ /** 获取 域名列表 */
53
+ async fetchDomainList() {
54
+ const client = _1.AliYunAccessService.createClient(this.accessKeyId, this.accessKeySecret);
55
+ const describeDomainsRequest = new $Alidns20150109.DescribeDomainsRequest({});
56
+ const runtime = new $Util.RuntimeOptions({});
57
+ try {
58
+ const { body } = await client.describeDomainsWithOptions(describeDomainsRequest, runtime);
59
+ return body;
60
+ }
61
+ catch (error) {
62
+ console.error(error);
63
+ }
64
+ }
65
+ /** 获取 解析记录 列表 */
66
+ async fetchDomainRecords(domainName) {
67
+ const client = _1.AliYunAccessService.createClient(this.accessKeyId, this.accessKeySecret);
68
+ const describeDomainRecordsRequest = new $Alidns20150109.DescribeDomainRecordsRequest({
69
+ domainName,
70
+ });
71
+ const runtime = new $Util.RuntimeOptions({});
72
+ try {
73
+ const { body } = await client.describeDomainRecordsWithOptions(describeDomainRecordsRequest, runtime);
74
+ return body;
75
+ }
76
+ catch (error) {
77
+ return null;
78
+ }
79
+ }
80
+ /** 定位 子域名解析记录 */
81
+ async findSubDomainRecords(domainName, RR) {
82
+ const records = await this.fetchDomainRecords(domainName);
83
+ return records?.domainRecords?.record.find(item => {
84
+ if (item.RR === RR) {
85
+ return item;
86
+ }
87
+ return false;
88
+ });
89
+ }
90
+ /** 更新 解析记录 备注 */
91
+ async updateDomainRecordRemarkRequest(recordId, remark) {
92
+ const client = _1.AliYunAccessService.createClient(this.accessKeyId, this.accessKeySecret);
93
+ const UpdateDomainRecordRemarkRequest = new $Alidns20150109.UpdateDomainRecordRemarkRequest({
94
+ recordId,
95
+ remark,
96
+ });
97
+ const runtime = new $Util.RuntimeOptions({});
98
+ try {
99
+ const { body } = await client.updateDomainRecordRemarkWithOptions(UpdateDomainRecordRemarkRequest, runtime);
100
+ return body;
101
+ }
102
+ catch (error) {
103
+ return null;
104
+ }
105
+ }
106
+ /** 更新 子域名 解析记录 */
107
+ async updateDomainRecord(domainName, RR, type, value) {
108
+ const findDomain = await this.findSubDomainRecords(domainName, RR);
109
+ if (constants_1.IS_DEV) {
110
+ console.log({ domainName, RR, type, value, findDomain });
111
+ }
112
+ if (type === undefined || value === undefined || !findDomain) {
113
+ return false;
114
+ }
115
+ // 如果解析值相同则跳出更新
116
+ if (findDomain.value === value && findDomain.type === type) {
117
+ return true;
118
+ }
119
+ // console.log({ value })
120
+ const recordId = findDomain.recordId;
121
+ const client = _1.AliYunAccessService.createClient(this.accessKeyId, this.accessKeySecret);
122
+ const updateDomainRecordRequest = new $Alidns20150109.UpdateDomainRecordRequest({
123
+ recordId,
124
+ RR,
125
+ type,
126
+ value,
127
+ });
128
+ const runtime = new $Util.RuntimeOptions({});
129
+ try {
130
+ const { body } = await client.updateDomainRecordWithOptions(updateDomainRecordRequest, runtime);
131
+ logger.info(`[AIAuthUpdateRecord]: ${RR}.${domainName} 授权OK...${value}`);
132
+ // Logger.custom('schedule').trace(`[${domainName}域名解析更新]: `, body)
133
+ // console.log(value)
134
+ // QQbot?.findGuild(QQ_GUILD.ISCS.child['变更通知'])?.sendMessage([
135
+ // `[${RR}.${domainName}域名解析更新]: ${value}`,
136
+ // ])
137
+ // const channel = QQbot?.findGuild(QQ_GUILD.ISCS.child['变更通知']);
138
+ // QQRobot.reply(
139
+ // channel,
140
+ // `[${RR}.${domainName}域名解析更新]: ${value}`,
141
+ // text => channel?.sendMessage(text as Sendable),
142
+ // );
143
+ await this.updateDomainRecordRemarkRequest(recordId, `${(0, dayjs_1.default)().format('YYYY-MM-DD HH-mm-ss')}更新`);
144
+ return body;
145
+ }
146
+ catch (error) {
147
+ return null;
148
+ }
149
+ }
150
+ }
151
+ exports.AliYun = AliYun;
@@ -0,0 +1,12 @@
1
+ import Alidns20150109 from '@alicloud/alidns20150109';
2
+ export declare class AliYunAccessService {
3
+ static instance: Alidns20150109;
4
+ /**
5
+ * 使用AK&SK初始化账号Client
6
+ * @param accessKeyId
7
+ * @param accessKeySecret
8
+ * @return Client
9
+ * @throws Exception
10
+ */
11
+ static createClient(accessKeyId?: string, accessKeySecret?: string): Alidns20150109;
12
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AliYunAccessService = void 0;
40
+ const alidns20150109_1 = __importDefault(require("@alicloud/alidns20150109"));
41
+ const $OpenApi = __importStar(require("@alicloud/openapi-client"));
42
+ class AliYunAccessService {
43
+ /**
44
+ * 使用AK&SK初始化账号Client
45
+ * @param accessKeyId
46
+ * @param accessKeySecret
47
+ * @return Client
48
+ * @throws Exception
49
+ */
50
+ static createClient(accessKeyId, accessKeySecret) {
51
+ if (AliYunAccessService.instance) {
52
+ return AliYunAccessService.instance;
53
+ }
54
+ const config = new $OpenApi.Config({
55
+ accessKeyId: accessKeyId ?? process.env.ALI_YUN_ACCESS_KEY_ID,
56
+ accessKeySecret: accessKeySecret ?? process.env.ALI_YUN_ACCESS_KEY_SECRET,
57
+ });
58
+ // 访问的域名
59
+ config.endpoint = `alidns.cn-hangzhou.aliyuncs.com`;
60
+ AliYunAccessService.instance = new alidns20150109_1.default(config);
61
+ return AliYunAccessService.instance;
62
+ }
63
+ }
64
+ exports.AliYunAccessService = AliYunAccessService;
@@ -0,0 +1,19 @@
1
+ import { AliYun } from './client';
2
+ export declare class AliYunLocalDomain {
3
+ private readonly ali;
4
+ readonly watchDomains: Record<string, {
5
+ RRs: string[];
6
+ }>;
7
+ constructor(ali: AliYun, watchDomains: Record<string, {
8
+ RRs: string[];
9
+ }>);
10
+ /** 定位子域名解析记录 为本机ip */
11
+ updateMainDomainRecordInLocalIP(routerPwd?: string): Promise<boolean>;
12
+ /**
13
+ * 获取本机外网IP
14
+ */
15
+ getClientIP(routerPwd?: string, isDebug?: boolean): Promise<{
16
+ ident: string;
17
+ ip: "";
18
+ }>;
19
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AliYunLocalDomain = void 0;
4
+ const constants_1 = require("../constants");
5
+ const huawei_1 = require("../utils/huawei");
6
+ const type_1 = require("./type");
7
+ class AliYunLocalDomain {
8
+ constructor(ali, watchDomains) {
9
+ this.ali = ali;
10
+ this.watchDomains = watchDomains;
11
+ }
12
+ /** 定位子域名解析记录 为本机ip */
13
+ async updateMainDomainRecordInLocalIP(routerPwd) {
14
+ const getNetwork = routerPwd ? await this.getClientIP(routerPwd) : null;
15
+ const fetchIP = getNetwork?.ident === 'huawei' ? getNetwork?.ip : '';
16
+ const [IP] = fetchIP?.match?.(/(?<=\s(\(|\[))(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?=\)|\])/) || [fetchIP];
17
+ const updateList = [];
18
+ Object.entries(this.watchDomains).forEach(([domainName, { RRs }]) => updateList.push(...RRs.map(RR => [domainName, RR])));
19
+ if (constants_1.IS_DEV) {
20
+ console.log({ IP, fetchIP, getNetwork, updateList });
21
+ }
22
+ if (IP) {
23
+ const result = (await Promise.all(await updateList.map(async ([updateDomain, RR]) => await this.ali.updateDomainRecord(updateDomain, RR, type_1.DomainRecordsExplorerType.A, IP)))).some(v => v);
24
+ return result;
25
+ }
26
+ }
27
+ /**
28
+ * 获取本机外网IP
29
+ */
30
+ async getClientIP(routerPwd, isDebug = false) {
31
+ const topGetIP = await (0, huawei_1.getLocalNetworkActive)(routerPwd);
32
+ if (topGetIP) {
33
+ return { ident: 'huawei', ip: topGetIP.IPv4Addr };
34
+ }
35
+ // const IPRegExp = /\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}/g
36
+ // const getContentIP = (text: string, name) => {
37
+ // const ip = (text.match(IPRegExp) || [])[0]
38
+ // isDebug && console.log(`[GetClientIP-DeBug]: `, { name, ip, text })
39
+ // return ip
40
+ // }
41
+ // // const fetchSohu = async () =>
42
+ // // await axios.get('http://pv.sohu.com/cityjson').then(res => getContentIP(res.data, 'fetchSohu'))
43
+ // const fetchL2 = async () =>
44
+ // await $axios.get('http://l2.io/ip.js').then(res => getContentIP(res.data, 'fetchL2'))
45
+ // const fetchIpinfo = async () =>
46
+ // await $axios
47
+ // .get('https://ipinfo.io/json?callback=recordData')
48
+ // .then(res => getContentIP(res.data, 'fetchIpinfo'))
49
+ // const fetchIp138 = async () =>
50
+ // await $axios.get('https://2022.ip138.com/').then(res => getContentIP(res.data, 'fetchIp138'))
51
+ // return /*fetchSohu() || */ {
52
+ // ident: 'other',
53
+ // ip: (await fetchL2()) || (await fetchIpinfo()) || (await fetchIp138()),
54
+ // }
55
+ }
56
+ }
57
+ exports.AliYunLocalDomain = AliYunLocalDomain;
@@ -0,0 +1,23 @@
1
+ /** 域名记录解析类型 */
2
+ export declare enum DomainRecordsExplorerType {
3
+ /** A记录 参考标准;RR值可为空,即@解析;不允许含有下划线; IPv4地址格式 */
4
+ 'A' = "A",
5
+ /** NS记录 参考标准;RR值不能为空;允许含有下划线;不支持泛解析 NameType形式 */
6
+ 'NS' = "NS",
7
+ /** MX记录 参考标准;RR值可为空,即@解析;不允许含有下划线 NameType形式,且不可为IP地址。1-10,优先级依次递减。 */
8
+ 'MX' = "MX",
9
+ /** TXT记录 参考标准;另外,有效字符除字母、数字、“-”(中横杠)、还包括“_”(下划线);RR值可为空,即@解析;允许含有下划线;不支持泛解析 字符串;长度小于512,合法字符:大小写字母,数字,空格,及以下字符:-~=:;/.@+^!* */
10
+ 'TXT' = "TXT",
11
+ /** CNAME记录 参考标准;另外,有效字符除字母、数字、“-”(中横杠)、还包括“_”(下划线);RR值不允许为空(即@);允许含有下划线 NameType形式,且不可为IP */
12
+ 'CNAME' = "CNAME",
13
+ /** SRV记录 是一个name,且可含有下划线“_“和点“.”;允许含有下划线;可为空(即@);不支持泛解析 priority:优先级,为0-65535之间的数字;weight:权重,为0-65535之间的数字;port:提供服务的端口号,为0-65535之间的数字 target:为提供服务的目标地址,为nameType,且存在。参考:http://en.wikipedia.org/wiki/SRV_record http://www.rfc-editor.org/rfc/rfc2782.txt */
14
+ 'SRV' = "SRV",
15
+ /** AAAA记录 参考标准;RR值可为空,即@解析;不允许含有下划线; IPv6地址格式 */
16
+ 'AAAA' = "AAAA",
17
+ /** CAA记录 参考标准;RR值可为空,即@解析;不允许含有下划线; 格式为:[flag] [tag] [value],是由一个标志字节的[flag],和一个被称为属性的标签[tag]-值[value]对组成。例如:@ 0 issue "symantec.com"或@ 0 iodef "mailto:admin@aliyun.com" */
18
+ 'CAA' = "CAA",
19
+ /** 显性URL转发 参考标准;RR值可为空,即@解析 NameType或URL地址(区分大小写),长度最长为500字符,其中域名,如a.com,必须,大小写不敏感;协议:可选,如http、https,默认为http端口:可选,如81,默认为80;路径:可选,大小写敏感,如/path/to/,默认为/;文件名:可选,大小写敏感,如file.php,默认无;参数:可选,大小写敏感,如?user=my***,默认无。 */
20
+ 'REDIRECT_URL' = "REDIRECT_URL",
21
+ /** 隐性URL转发 参考标准;RR值可为空,即@解析 NameType或URL地址(区分大小写),长度最长为500字符,其中域名,如a.com,必须,大小写不敏感;协议:可选,如http、https,默认为http端口:可选,如81,默认为80;路径:可选,大小写敏感,如/path/to/,默认为/;文件名:可选,大小写敏感,如file.php,默认无;参数:可选,大小写敏感,如?user=my***,默认无。 */
22
+ 'FORWARD_URL' = "FORWARD_URL"
23
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DomainRecordsExplorerType = void 0;
4
+ /** 域名记录解析类型 */
5
+ var DomainRecordsExplorerType;
6
+ (function (DomainRecordsExplorerType) {
7
+ /** A记录 参考标准;RR值可为空,即@解析;不允许含有下划线; IPv4地址格式 */
8
+ DomainRecordsExplorerType["A"] = "A";
9
+ /** NS记录 参考标准;RR值不能为空;允许含有下划线;不支持泛解析 NameType形式 */
10
+ DomainRecordsExplorerType["NS"] = "NS";
11
+ /** MX记录 参考标准;RR值可为空,即@解析;不允许含有下划线 NameType形式,且不可为IP地址。1-10,优先级依次递减。 */
12
+ DomainRecordsExplorerType["MX"] = "MX";
13
+ /** TXT记录 参考标准;另外,有效字符除字母、数字、“-”(中横杠)、还包括“_”(下划线);RR值可为空,即@解析;允许含有下划线;不支持泛解析 字符串;长度小于512,合法字符:大小写字母,数字,空格,及以下字符:-~=:;/.@+^!* */
14
+ DomainRecordsExplorerType["TXT"] = "TXT";
15
+ /** CNAME记录 参考标准;另外,有效字符除字母、数字、“-”(中横杠)、还包括“_”(下划线);RR值不允许为空(即@);允许含有下划线 NameType形式,且不可为IP */
16
+ DomainRecordsExplorerType["CNAME"] = "CNAME";
17
+ /** SRV记录 是一个name,且可含有下划线“_“和点“.”;允许含有下划线;可为空(即@);不支持泛解析 priority:优先级,为0-65535之间的数字;weight:权重,为0-65535之间的数字;port:提供服务的端口号,为0-65535之间的数字 target:为提供服务的目标地址,为nameType,且存在。参考:http://en.wikipedia.org/wiki/SRV_record http://www.rfc-editor.org/rfc/rfc2782.txt */
18
+ DomainRecordsExplorerType["SRV"] = "SRV";
19
+ /** AAAA记录 参考标准;RR值可为空,即@解析;不允许含有下划线; IPv6地址格式 */
20
+ DomainRecordsExplorerType["AAAA"] = "AAAA";
21
+ /** CAA记录 参考标准;RR值可为空,即@解析;不允许含有下划线; 格式为:[flag] [tag] [value],是由一个标志字节的[flag],和一个被称为属性的标签[tag]-值[value]对组成。例如:@ 0 issue "symantec.com"或@ 0 iodef "mailto:admin@aliyun.com" */
22
+ DomainRecordsExplorerType["CAA"] = "CAA";
23
+ /** 显性URL转发 参考标准;RR值可为空,即@解析 NameType或URL地址(区分大小写),长度最长为500字符,其中域名,如a.com,必须,大小写不敏感;协议:可选,如http、https,默认为http端口:可选,如81,默认为80;路径:可选,大小写敏感,如/path/to/,默认为/;文件名:可选,大小写敏感,如file.php,默认无;参数:可选,大小写敏感,如?user=my***,默认无。 */
24
+ DomainRecordsExplorerType["REDIRECT_URL"] = "REDIRECT_URL";
25
+ /** 隐性URL转发 参考标准;RR值可为空,即@解析 NameType或URL地址(区分大小写),长度最长为500字符,其中域名,如a.com,必须,大小写不敏感;协议:可选,如http、https,默认为http端口:可选,如81,默认为80;路径:可选,大小写敏感,如/path/to/,默认为/;文件名:可选,大小写敏感,如file.php,默认无;参数:可选,大小写敏感,如?user=my***,默认无。 */
26
+ DomainRecordsExplorerType["FORWARD_URL"] = "FORWARD_URL";
27
+ })(DomainRecordsExplorerType || (exports.DomainRecordsExplorerType = DomainRecordsExplorerType = {}));
@@ -0,0 +1,20 @@
1
+ import { Argv } from 'koishi';
2
+ import { MCSManagerBot } from '../../mcsManager/bot';
3
+ export declare enum BotCommandRole {
4
+ /** 群主 */
5
+ Owner = "owner",
6
+ /** 管理员 */
7
+ Admin = "admin",
8
+ /** 成员 */
9
+ Member = "member",
10
+ /** 所有人 */
11
+ All = "all"
12
+ }
13
+ export declare abstract class BotCommandBase {
14
+ readonly bot: MCSManagerBot;
15
+ abstract command: string[];
16
+ abstract roles: BotCommandRole[];
17
+ constructor(bot: MCSManagerBot);
18
+ authenticate(cmd: Argv, args: string[]): Promise<string>;
19
+ abstract handle?(cmd: Argv, args: string[]): Promise<string>;
20
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BotCommandBase = exports.BotCommandRole = void 0;
4
+ const koishi_1 = require("koishi");
5
+ const logger = new koishi_1.Logger('mcsmanager-command');
6
+ var BotCommandRole;
7
+ (function (BotCommandRole) {
8
+ /** 群主 */
9
+ BotCommandRole["Owner"] = "owner";
10
+ /** 管理员 */
11
+ BotCommandRole["Admin"] = "admin";
12
+ /** 成员 */
13
+ BotCommandRole["Member"] = "member";
14
+ /** 所有人 */
15
+ BotCommandRole["All"] = "all";
16
+ })(BotCommandRole || (exports.BotCommandRole = BotCommandRole = {}));
17
+ class BotCommandBase {
18
+ constructor(bot) {
19
+ this.bot = bot;
20
+ }
21
+ // 鉴定权限
22
+ async authenticate(cmd, args) {
23
+ // console.log(cmd.session.event);
24
+ const userRole = cmd.session.event.member?.roles?.at(0);
25
+ if (this.roles.length > 0 &&
26
+ !this.roles.includes(userRole)) {
27
+ logger.error(`用户 ${cmd.session.event.user.id}[${userRole}] 没有权限使用指令 ${this.command}`);
28
+ return '您没有权限使用此指令。';
29
+ }
30
+ return await this.handle?.(cmd, args);
31
+ }
32
+ }
33
+ exports.BotCommandBase = BotCommandBase;
@@ -0,0 +1 @@
1
+ export * as GLBaseCommands from './base';
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.GLBaseCommands = void 0;
37
+ exports.GLBaseCommands = __importStar(require("./base"));
@@ -0,0 +1,6 @@
1
+ import { BotCommandBase } from './base';
2
+ export declare class GLCommandRegister {
3
+ static commands: Record<string, BotCommandBase>;
4
+ static mainCommands: Set<string>;
5
+ static commandRegExp: Record<string, RegExp>;
6
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GLCommandRegister = void 0;
4
+ class GLCommandRegister {
5
+ }
6
+ exports.GLCommandRegister = GLCommandRegister;
7
+ // 注册的指令列表
8
+ GLCommandRegister.commands = {};
9
+ // 主指令列表
10
+ GLCommandRegister.mainCommands = new Set();
11
+ // 指令正则表达式列表
12
+ GLCommandRegister.commandRegExp = {};
@@ -0,0 +1,21 @@
1
+ import { Schema } from 'koishi';
2
+ export declare class GLConfig {
3
+ static Base: Schema<Schemastery.ObjectS<{
4
+ cmdRegisterMode: Schema<boolean, boolean>;
5
+ }>, Schemastery.ObjectT<{
6
+ cmdRegisterMode: Schema<boolean, boolean>;
7
+ }>>;
8
+ static Extends: Schema<Schemastery.ObjectS<{
9
+ authKey: Schema<string, string>;
10
+ authID: Schema<string, string>;
11
+ authSecret: Schema<string, string>;
12
+ authDomain: Schema<string, string>;
13
+ authChildDomain: Schema<string[], string[]>;
14
+ }>, Schemastery.ObjectT<{
15
+ authKey: Schema<string, string>;
16
+ authID: Schema<string, string>;
17
+ authSecret: Schema<string, string>;
18
+ authDomain: Schema<string, string>;
19
+ authChildDomain: Schema<string[], string[]>;
20
+ }>>;
21
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GLConfig = void 0;
4
+ const koishi_1 = require("koishi");
5
+ class GLConfig {
6
+ }
7
+ exports.GLConfig = GLConfig;
8
+ GLConfig.Base = koishi_1.Schema.object({
9
+ cmdRegisterMode: koishi_1.Schema.boolean()
10
+ .default(false)
11
+ .description('命令注册模式 指令模式/关键词模式'),
12
+ }).description('GL 基础配置');
13
+ GLConfig.Extends = koishi_1.Schema.object({
14
+ authKey: koishi_1.Schema.string().role('secret').description('AI服务授权密钥'),
15
+ authID: koishi_1.Schema.string().role('secret').description('AI服务授权ID'),
16
+ authSecret: koishi_1.Schema.string().role('secret').description('AI服务授权密钥2'),
17
+ authDomain: koishi_1.Schema.string().description('AI服务授权域名'),
18
+ authChildDomain: koishi_1.Schema.array(String).description('AI服务授权子域名'),
19
+ }).description('GL 拓展配置');
package/lib/gl/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Context, Schema } from 'koishi';
2
+ import { AliYun } from '../ali/client';
2
3
  import { MCManager } from '../mcsManager';
3
4
  import { NapCat } from '../napCat';
4
5
  import { GLQueQiaoAdapter } from './queqiao.adapter';
@@ -7,6 +8,14 @@ export declare class GLBot {
7
8
  private config;
8
9
  static inject: string[];
9
10
  static Config: Schema<Schemastery.ObjectS<{
11
+ cmdRegisterMode: Schema<boolean, boolean>;
12
+ }> | Schemastery.ObjectS<{
13
+ authKey: Schema<string, string>;
14
+ authID: Schema<string, string>;
15
+ authSecret: Schema<string, string>;
16
+ authDomain: Schema<string, string>;
17
+ authChildDomain: Schema<string[], string[]>;
18
+ }> | Schemastery.ObjectS<{
10
19
  mcManagerUsername: Schema<string, string>;
11
20
  mcManagerPassword: Schema<string, string>;
12
21
  mcManagerKey: Schema<string, string>;
@@ -36,13 +45,21 @@ export declare class GLBot {
36
45
  napCatBaseUrl: Schema<string, string>;
37
46
  napCatToken: Schema<string, string>;
38
47
  }>, {
48
+ cmdRegisterMode: boolean;
49
+ } & import("cosmokit").Dict & {
50
+ authKey: string;
51
+ authID: string;
52
+ authSecret: string;
53
+ authDomain: string;
54
+ authChildDomain: string[];
55
+ } & {
39
56
  mcManagerUsername: string;
40
57
  mcManagerPassword: string;
41
58
  mcManagerKey: string;
42
59
  mcManagerHost: string;
43
60
  mcManagerWs: string;
44
61
  mcManagerMaxConnectWs: number;
45
- } & import("cosmokit").Dict & {
62
+ } & {
46
63
  queQiaoEnable: boolean;
47
64
  queQiaoSendToChannel: string[];
48
65
  queQiaoWatchChannel: string[];
@@ -61,8 +78,12 @@ export declare class GLBot {
61
78
  readonly mcsManager: MCManager;
62
79
  readonly queQiaoAdapter: GLQueQiaoAdapter;
63
80
  readonly napCat: NapCat;
81
+ readonly ali: AliYun;
82
+ private updateDomainRecordsInLocalIPInterval;
64
83
  constructor(ctx: Context, config: GLBotConfigType);
65
84
  private initialize;
85
+ private updateDomainRecordsInLocalIP;
86
+ dispose(): void;
66
87
  private globalCommand;
67
88
  }
68
89
  export declare class GLBotBase {