mm_os 2.5.0 → 2.5.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.
@@ -14,7 +14,7 @@ class Drive extends Item {
14
14
  constructor(dir) {
15
15
  super(dir, __dirname);
16
16
  this.default_file = "./plugin.json";
17
-
17
+
18
18
  /**
19
19
  * 当前语言
20
20
  */
@@ -59,11 +59,27 @@ class Drive extends Item {
59
59
  // 是否中断执行
60
60
  "end": true,
61
61
  // 排序
62
- "sort": 10
62
+ "sort": 10,
63
+ // 配置
64
+ "options": []
63
65
  };
64
66
  }
65
67
  }
66
68
 
69
+ /**
70
+ * 获取配置参数
71
+ * @return {Object} 返回配置参数
72
+ */
73
+ Drive.prototype.options = function() {
74
+ var op = this.config.options || [];
75
+ var dict = {};
76
+ for (var i = 0; i < op.length; i++) {
77
+ var o = op[i];
78
+ dict[o.name] = o.value;
79
+ }
80
+ return dict;
81
+ }
82
+
67
83
  /**
68
84
  * 新建脚本
69
85
  * @param {String} 文件
@@ -111,7 +127,8 @@ Drive.prototype.new_config = function(file) {
111
127
  text = text.replaceAll('{0}', name);
112
128
  } else if (file.indexOf('app' + l) !== -1) {
113
129
  name = file.between('app' + l, l);
114
- text = text.replaceAll('{0}', name).replaceAll('\r\n "app": "{1}",', '').replaceAll('插件', '应用').replaceAll('{2}', name);
130
+ text = text.replaceAll('{0}', name).replaceAll('\r\n "app": "{1}",', '').replaceAll('插件', '应用')
131
+ .replaceAll('{2}', name);
115
132
  }
116
133
  file.saveText(text);
117
134
  }
@@ -347,4 +364,4 @@ Drive.prototype.exec = function(func_name, option) {
347
364
  return msg;
348
365
  };
349
366
 
350
- module.exports = Drive;
367
+ module.exports = Drive;
@@ -56,7 +56,7 @@ module.exports = {
56
56
  */
57
57
  start(option) {
58
58
  var msg = null;
59
- console.log("启动了", this.config);
59
+ console.log("启动了", this.options());
60
60
  return msg;
61
61
  },
62
62
 
@@ -22,5 +22,82 @@
22
22
  // 是否中断执行
23
23
  "end": true,
24
24
  // 排序,表示多个插件时在应用下执行的先后顺序
25
- "sort": 10
25
+ "sort": 10,
26
+ // 配置参数
27
+ "options": [
28
+ {
29
+ "group": "默认",
30
+ "config_id": 0,
31
+ "name": "appId",
32
+ "title": "机器人ID",
33
+ "type": "string",
34
+ "control": "input",
35
+ "tip": "例:102047156",
36
+ "description": "官方申请的QQ机器人ID,详情请查看<a target=\"_blank\" href=\"https://q.qq.com/#/app/bot\">QQ开放平台</a>",
37
+ "display": 100,
38
+ "default": "102047156",
39
+ "min": 0,
40
+ "max": 0,
41
+ "value": "102047156"
42
+ },
43
+ {
44
+ "group": "默认",
45
+ "config_id": 0,
46
+ "name": "AppSecret",
47
+ "title": "机器人密钥",
48
+ "type": "string",
49
+ "control": "input",
50
+ "tip": "例:ufQBwiUG2oaM9wjWJ6tgUI6uiWK9yncR1",
51
+ "description": "用于在 oauth 场景进行请求签名的密钥",
52
+ "display": 100,
53
+ "default": "ufQBwiUG2oaM9wjWJ6tgUI6uiWK9yncR1",
54
+ "min": 0,
55
+ "max": 0,
56
+ "value": "ufQBwiUG2oaM9wjWJ6tgUI6uiWK9yncR1"
57
+ },
58
+ {
59
+ "group": "默认",
60
+ "config_id": 0,
61
+ "name": "token",
62
+ "title": "机器人令牌",
63
+ "type": "string",
64
+ "control": "input",
65
+ "tip": "例:w14e85M4Mj6egshfKc3wADq1KMP87Qi3",
66
+ "description": "用于以机器人身份调用 openapi",
67
+ "display": 100,
68
+ "default": "w14e85M4Mj6egshfKc3wADq1KMP87Qi3",
69
+ "min": 0,
70
+ "max": 0,
71
+ "value": "w14e85M4Mj6egshfKc3wADq1KMP87Qi3"
72
+ },
73
+ {
74
+ "group": "默认",
75
+ "config_id": 0,
76
+ "name": "intents",
77
+ "title": "事件订阅",
78
+ "type": "string",
79
+ "control": "checkbox",
80
+ "tip": "",
81
+ "description": "用于开启可接收的消息类型",
82
+ "display": 100,
83
+ "default": "PUBLIC_GUILD_MESSAGES",
84
+ "min": 1,
85
+ "max": 255,
86
+ "model": "公域消息事件=PUBLIC_GUILD_MESSAGES\n私域消息事件=GUILD_MESSAGES"
87
+ },
88
+ {
89
+ "group": "默认",
90
+ "config_id": 0,
91
+ "name": "sandbox",
92
+ "title": "沙箱",
93
+ "type": "boolean",
94
+ "control": "switch",
95
+ "tip": "",
96
+ "description": "沙箱支持,可选,默认false. v2.7.0+",
97
+ "display": 100,
98
+ "default": "false",
99
+ "min": 0,
100
+ "max": 1
101
+ }
102
+ ]
26
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {