Skip to content

Commit

Permalink
update 3.3
Browse files Browse the repository at this point in the history
弃用hml格式存储,改用sqlite存储开关数据
网页操作`修改`操作.
使用独立插件(不要依赖jar但同时不能与其他相关插件共同使用例如AutoReply
优化json输出算法
可能相关issue #1 #8 #6 #2
  • Loading branch information
Kloping committed Mar 21, 2024
1 parent 29e1138 commit dc5660f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "io.github.gdpl2112"
version = "3.2"
version = "3.3"

repositories {
maven("https://repo1.maven.org/maven2/")
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/github/gdpl2112/mirai/p1/CallApiPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public class CallApiPlugin extends JavaPlugin {
public static Conf conf = null;

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

Expand Down
15 changes: 10 additions & 5 deletions src/main/java/io/github/gdpl2112/mirai/p1/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ public static Object get(Connection t1, String t0, AtomicReference<Document> doc
public static Object get0(String t1, String t0) throws Exception {
JSON j0 = (JSON) JSON.parse(t1);
t0 = t0.trim();
String s0 = t0.trim().split("\\.")[0].trim();
String s0 = null;
for (String s : t0.trim().split("\\.")) {
if (!s.isEmpty()) {
s0 = s;
break;
}
}
Object o = null;
if (s0.matches("\\[\\d*]")) {
JSONArray arr = (JSONArray) j0;
Expand All @@ -126,17 +132,16 @@ public static Object get0(String t1, String t0) throws Exception {
Integer st = Integer.parseInt(s0.substring(i + 1, s0.length() - 1));
JSONObject jo = (JSONObject) j0;
o = jo.getJSONArray(st0).get(st);
int len = 4 + st0.length();
if (t0.length() >= len) t0 = t0.substring(len);
else t0 = t0.substring(len - 1);
if (t0.length() > s0.length()) t0 = t0.substring(s0.length());
else t0 = null;
} else {
JSONObject jo = (JSONObject) j0;
o = jo.get(s0);
int len = s0.length() + 1;
if (t0.length() >= len) t0 = t0.substring(len);
else t0 = t0.substring(len - 1);
}
if (t0.length() > 0) {
if (t0 != null && t0.length() > 0) {
return get0(JSON.toJSONString(o), t0);
} else {
return o;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Object append(
template.setTouch(touch);
}
template.setOut(out);
template.setOutArgs(outArgs.split(","));
template.setOutArgs(outArgs.split(",|;"));
template.setUrl(url);
if (proxy != null && !proxy.isEmpty()) {
template.setProxyIp(proxy.split(":")[0]);
Expand Down
19 changes: 15 additions & 4 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h5 class="modal-title" id="exampleModalLabel">添加一个API</h5>
</div>
<div class="input-group mb-3">
<span class="input-group-text" id="inputGroup-outArgs">输出参数</span>
<input placeholder="用,分割参数(英文" type="text" class="form-control"
<input placeholder="用,或;分割参数(英文)" type="text" class="form-control"
aria-label="Sizing example input">
</div>
<div class="input-group mb-3">
Expand Down Expand Up @@ -142,7 +142,19 @@ <h5 class="modal-title" id="exampleModalLabel">添加一个API</h5>
}, getStrs: function (es) {
let s0 = "";
for (e0 of es) {
s0 = s0 + "\n" + e0;
s0 = s0 + "\r\n" + e0;
}
return s0.trim();
}, getStrs1: function (es) {
let s0 = "";
let k = true
for (e0 of es) {
if (k) {
s0 = e0;
k = false
} else {
s0 = s0 + "," + e0;
}
}
return s0.trim();
}, delete0: function (touch) {
Expand All @@ -153,12 +165,11 @@ <h5 class="modal-title" id="exampleModalLabel">添加一个API</h5>
})
}, ope: function (e) {
e_out.val(e.out)
e_outArgs.val(this.getStrs(e.outArgs))
e_outArgs.val(this.getStrs1(e.outArgs))
e_proxy.val(e.proxyIp + ':' + e.proxyPort)
e_touch.val(e.touch)
e_url.val(e.url)
$('#appendModal').modal('show')

}
}
});
Expand Down

0 comments on commit dc5660f

Please sign in to comment.