Skip to content

Commit dc5660f

Browse files
committed
update 3.3
弃用hml格式存储,改用sqlite存储开关数据 网页操作`修改`操作. 使用独立插件(不要依赖jar但同时不能与其他相关插件共同使用例如AutoReply 优化json输出算法 可能相关issue #1 #8 #6 #2
1 parent 29e1138 commit dc5660f

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
group = "io.github.gdpl2112"
11-
version = "3.2"
11+
version = "3.3"
1212

1313
repositories {
1414
maven("https://repo1.maven.org/maven2/")

src/main/java/io/github/gdpl2112/mirai/p1/CallApiPlugin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public class CallApiPlugin extends JavaPlugin {
2727
public static Conf conf = null;
2828

2929
public CallApiPlugin() {
30-
super(new JvmPluginDescriptionBuilder("io.github.Kloping.mirai.p1.CallApiPlugin", "3.2")
31-
.dependsOn("io.github.gdpl2112.lib-tts", true)
30+
super(new JvmPluginDescriptionBuilder("io.github.Kloping.mirai.p1.CallApiPlugin", "3.3")
3231
.info("调用自定义API插件").build());
3332
}
3433

src/main/java/io/github/gdpl2112/mirai/p1/Converter.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ public static Object get(Connection t1, String t0, AtomicReference<Document> doc
104104
public static Object get0(String t1, String t0) throws Exception {
105105
JSON j0 = (JSON) JSON.parse(t1);
106106
t0 = t0.trim();
107-
String s0 = t0.trim().split("\\.")[0].trim();
107+
String s0 = null;
108+
for (String s : t0.trim().split("\\.")) {
109+
if (!s.isEmpty()) {
110+
s0 = s;
111+
break;
112+
}
113+
}
108114
Object o = null;
109115
if (s0.matches("\\[\\d*]")) {
110116
JSONArray arr = (JSONArray) j0;
@@ -126,17 +132,16 @@ public static Object get0(String t1, String t0) throws Exception {
126132
Integer st = Integer.parseInt(s0.substring(i + 1, s0.length() - 1));
127133
JSONObject jo = (JSONObject) j0;
128134
o = jo.getJSONArray(st0).get(st);
129-
int len = 4 + st0.length();
130-
if (t0.length() >= len) t0 = t0.substring(len);
131-
else t0 = t0.substring(len - 1);
135+
if (t0.length() > s0.length()) t0 = t0.substring(s0.length());
136+
else t0 = null;
132137
} else {
133138
JSONObject jo = (JSONObject) j0;
134139
o = jo.get(s0);
135140
int len = s0.length() + 1;
136141
if (t0.length() >= len) t0 = t0.substring(len);
137142
else t0 = t0.substring(len - 1);
138143
}
139-
if (t0.length() > 0) {
144+
if (t0 != null && t0.length() > 0) {
140145
return get0(JSON.toJSONString(o), t0);
141146
} else {
142147
return o;

src/main/java/io/github/gdpl2112/mirai/p1/rest/RestController0.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Object append(
8989
template.setTouch(touch);
9090
}
9191
template.setOut(out);
92-
template.setOutArgs(outArgs.split(","));
92+
template.setOutArgs(outArgs.split(",|;"));
9393
template.setUrl(url);
9494
if (proxy != null && !proxy.isEmpty()) {
9595
template.setProxyIp(proxy.split(":")[0]);

src/main/resources/static/index.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h5 class="modal-title" id="exampleModalLabel">添加一个API</h5>
3535
</div>
3636
<div class="input-group mb-3">
3737
<span class="input-group-text" id="inputGroup-outArgs">输出参数</span>
38-
<input placeholder="用,分割参数(英文" type="text" class="form-control"
38+
<input placeholder="用,或;分割参数(英文)" type="text" class="form-control"
3939
aria-label="Sizing example input">
4040
</div>
4141
<div class="input-group mb-3">
@@ -142,7 +142,19 @@ <h5 class="modal-title" id="exampleModalLabel">添加一个API</h5>
142142
}, getStrs: function (es) {
143143
let s0 = "";
144144
for (e0 of es) {
145-
s0 = s0 + "\n" + e0;
145+
s0 = s0 + "\r\n" + e0;
146+
}
147+
return s0.trim();
148+
}, getStrs1: function (es) {
149+
let s0 = "";
150+
let k = true
151+
for (e0 of es) {
152+
if (k) {
153+
s0 = e0;
154+
k = false
155+
} else {
156+
s0 = s0 + "," + e0;
157+
}
146158
}
147159
return s0.trim();
148160
}, delete0: function (touch) {
@@ -153,12 +165,11 @@ <h5 class="modal-title" id="exampleModalLabel">添加一个API</h5>
153165
})
154166
}, ope: function (e) {
155167
e_out.val(e.out)
156-
e_outArgs.val(this.getStrs(e.outArgs))
168+
e_outArgs.val(this.getStrs1(e.outArgs))
157169
e_proxy.val(e.proxyIp + ':' + e.proxyPort)
158170
e_touch.val(e.touch)
159171
e_url.val(e.url)
160172
$('#appendModal').modal('show')
161-
162173
}
163174
}
164175
});

0 commit comments

Comments
 (0)