Skip to content

Commit 7a1af23

Browse files
committed
新模块
1 parent 7df6ca7 commit 7a1af23

File tree

21 files changed

+505
-67
lines changed

21 files changed

+505
-67
lines changed

Lsys-GetPic/src/main/java/cn/kloping/lsys/getPic/Loader.java

+27-25
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.concurrent.ExecutorService;
2222
import java.util.concurrent.Executors;
2323

24+
import static cn.kloping.lsys.utils.MessageUtils.createImageInGroup;
25+
2426
public class Loader {
2527
public static Conf conf = new Conf(0, 12);
2628

@@ -54,7 +56,7 @@ public class Loader {
5456
}
5557
String name = request.getStr().substring(request.getOStr().indexOf("."));
5658
String names = URLEncoder.encode(name, "utf-8");
57-
JSONObject jo = JSON.parseObject(UrlUtils.getStringFromHttpUrl( String.format(baseUrl, names, conf.getNum(), "baidu")));
59+
JSONObject jo = JSON.parseObject(UrlUtils.getStringFromHttpUrl(String.format(baseUrl, names, conf.getNum(), "baidu")));
5860
startCd();
5961
ForwardMessageBuilder builder = new ForwardMessageBuilder(request.getEvent().getSubject());
6062
long id = request.getEvent().getBot().getId();
@@ -101,7 +103,7 @@ private static void startCd() {
101103
}
102104
String name = request.getStr().substring(request.getOStr().indexOf("."));
103105
String names = URLEncoder.encode(name, "utf-8");
104-
JSONObject jo = JSON.parseObject(UrlUtils.getStringFromHttpUrl( String.format(baseUrl, names, "1", "duit")));
106+
JSONObject jo = JSON.parseObject(UrlUtils.getStringFromHttpUrl(String.format(baseUrl, names, "1", "duit")));
105107
String picUrl = jo.getJSONArray("data").getString(0);
106108
startCd();
107109
return new Result(new Object[]{picUrl}, 0);
@@ -119,7 +121,7 @@ private static void startCd() {
119121
}
120122
String name = request.getStr().substring(request.getOStr().indexOf("."));
121123
String names = URLEncoder.encode(name, "utf-8");
122-
JSONObject jo = JSON.parseObject(UrlUtils.getStringFromHttpUrl( String.format(baseUrl, names, conf.getNum(), "duit")));
124+
JSONObject jo = JSON.parseObject(UrlUtils.getStringFromHttpUrl(String.format(baseUrl, names, conf.getNum(), "duit")));
123125
startCd();
124126
ForwardMessageBuilder builder = new ForwardMessageBuilder(request.getEvent().getSubject());
125127
long id = request.getEvent().getBot().getId();
@@ -144,27 +146,27 @@ private static void startCd() {
144146
};
145147

146148

147-
public static synchronized Image createImageInGroup(Contact group, String path) {
148-
try {
149-
if (path.startsWith("http")) {
150-
return Contact.uploadImage(group, new URL(path).openStream());
151-
} else if (path.startsWith("{")) {
152-
return Image.fromId(path);
153-
} else {
154-
Image image = null;
155-
image = Contact.uploadImage(group, new File(path));
156-
return image;
157-
}
158-
} catch (IOException e) {
159-
System.err.println(path + "加载重试");
160-
try {
161-
return Contact.uploadImage(group, new URL(path).openStream());
162-
} catch (IOException ioException) {
163-
ioException.printStackTrace();
164-
return null;
165-
}
166-
}
167-
}
149+
// public static synchronized Image createImageInGroup(Contact group, String path) {
150+
// try {
151+
// if (path.startsWith("http")) {
152+
// return Contact.uploadImage(group, new URL(path).openStream());
153+
// } else if (path.startsWith("{")) {
154+
// return Image.fromId(path);
155+
// } else {
156+
// Image image = null;
157+
// image = Contact.uploadImage(group, new File(path));
158+
// return image;
159+
// }
160+
// } catch (IOException e) {
161+
// System.err.println(path + "加载重试");
162+
// try {
163+
// return Contact.uploadImage(group, new URL(path).openStream());
164+
// } catch (IOException ioException) {
165+
// ioException.printStackTrace();
166+
// return null;
167+
// }
168+
// }
169+
// }
168170

169171
public static final Runnable runnable = () -> {
170172
if (!Resource.conf.getInvokeGroups().containsKey("getPic"))
@@ -176,7 +178,7 @@ public static void loadConf() {
176178
}
177179

178180
public static void applyConf() {
179-
cn.kloping.initialize.FileInitializeValue.putValues("./conf/Lsys/lsys-getPic.json", conf);
181+
cn.kloping.initialize.FileInitializeValue.putValues("./conf/Lsys/lsys-getPic.json", conf, true);
180182
}
181183

182184
public static void load() {

Lsys-PicParser/src/main/java/cn/kloping/lsys/picParser/PluginMain.java

-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ public void onLoad(@NotNull PluginComponentStorage $this$onLoad) {
2929
return;
3030
}
3131
try {
32-
getLogger().info("加载主要 功能中...");
3332
start();
3433
} catch (Exception e) {
3534
e.printStackTrace();
3635
}
37-
getLogger().info("加载完成");
3836
}
3937

4038
@Override

Lsys-PicParser/src/main/java/cn/kloping/lsys/picParser/picParser.java

+22-21
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.regex.Matcher;
2020
import java.util.regex.Pattern;
2121

22+
import static cn.kloping.lsys.utils.MessageUtils.createImageInGroup;
2223
import static cn.kloping.url.UrlUtils.getStringFromHttpUrl;
2324

2425
public class picParser {
@@ -147,25 +148,25 @@ public static String[] parseDyImgs(String url) {
147148
return null;
148149
}
149150

150-
public static synchronized Image createImageInGroup(Contact group, String path) {
151-
try {
152-
if (path.startsWith("http")) {
153-
return Contact.uploadImage(group, new URL(path).openStream());
154-
} else if (path.startsWith("{")) {
155-
return Image.fromId(path);
156-
} else {
157-
Image image = null;
158-
image = Contact.uploadImage(group, new File(path));
159-
return image;
160-
}
161-
} catch (IOException e) {
162-
System.err.println(path + "加载重试");
163-
try {
164-
return Contact.uploadImage(group, new URL(path).openStream());
165-
} catch (IOException ioException) {
166-
ioException.printStackTrace();
167-
return null;
168-
}
169-
}
170-
}
151+
// public static synchronized Image createImageInGroup(Contact group, String path) {
152+
// try {
153+
// if (path.startsWith("http")) {
154+
// return Contact.uploadImage(group, new URL(path).openStream());
155+
// } else if (path.startsWith("{")) {
156+
// return Image.fromId(path);
157+
// } else {
158+
// Image image = null;
159+
// image = Contact.uploadImage(group, new File(path));
160+
// return image;
161+
// }
162+
// } catch (IOException e) {
163+
// System.err.println(path + "加载重试");
164+
// try {
165+
// return Contact.uploadImage(group, new URL(path).openStream());
166+
// } catch (IOException ioException) {
167+
// ioException.printStackTrace();
168+
// return null;
169+
// }
170+
// }
171+
// }
171172
}

Lsys-Score1/pom.xml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>MiraiLSys</artifactId>
7+
<groupId>org.example</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>Lsys-Score1</artifactId>
13+
<dependencies>
14+
<dependency>
15+
<groupId>net.mamoe</groupId>
16+
<artifactId>mirai-console</artifactId>
17+
<version>2.8.0-RC</version>
18+
<scope>compile</scope>
19+
</dependency>
20+
<dependency>
21+
<groupId>org.example</groupId>
22+
<artifactId>MiraiLSys</artifactId>
23+
<version>1.0-SNAPSHOT</version>
24+
<scope>compile</scope>
25+
</dependency>
26+
</dependencies>
27+
28+
<properties>
29+
<maven.compiler.source>8</maven.compiler.source>
30+
<maven.compiler.target>8</maven.compiler.target>
31+
</properties>
32+
33+
</project>

Lsys-Score1/readme.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### MiraiLsys 子插件
2+
3+
###积分相关的操作
4+
下载
5+
6+
- 点歌的 [z2-Lsys-GetSong.jar ](https://github.com/Kloping/MiraiLsys/releases/download/0.1/z2-Lsys-GetSong.jar)
7+
- 同样若无极端情况请不要修改文件名 否则将无法正常工作
8+
9+
### 其命令
10+
11+
1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
package cn.kloping.lsys.sc1;
2+
3+
import cn.kloping.date.DateUtils;
4+
import cn.kloping.file.FileUtils;
5+
import cn.kloping.lsys.Resource;
6+
import cn.kloping.lsys.entitys.Request;
7+
import cn.kloping.lsys.entitys.Result;
8+
import cn.kloping.lsys.entitys.User;
9+
import cn.kloping.lsys.savers.PutGetter;
10+
import cn.kloping.lsys.utils.MessageUtils;
11+
import cn.kloping.number.NumberUtils;
12+
import kotlin.jvm.functions.Function2;
13+
14+
import java.io.*;
15+
16+
import static cn.kloping.lsys.utils.MessageUtils.random;
17+
18+
public class Methods {
19+
public static final Result state1 = new Result(new Object[]{}, 1);
20+
public static final Result state2 = new Result(new Object[]{}, 2);
21+
public static final Result state3 = new Result(new Object[]{}, 3);
22+
public static final Result state4 = new Result(new Object[]{}, 4);
23+
public static final Result state5 = new Result(new Object[]{}, 5);
24+
25+
public static final Function2<User, Request, Result> rob = (user, request) -> {
26+
long q2 = MessageUtils.getAtFromRequest(request);
27+
if (q2 == -1) return state1;
28+
User q2u = PutGetter.get(q2);
29+
if (q2u == null) return state2;
30+
if (user.getPf() >= 10) return state5;
31+
if (q2u.getP() >= 60) {
32+
if (user.getP() >= 60) {
33+
int r = random.nextInt(20) + 40;
34+
user.addP(r);
35+
user.addPf(1);
36+
q2u.addP(-r);
37+
user.apply();
38+
q2u.apply();
39+
return new Result(new Object[]{r}, 0);
40+
} else {
41+
return state4;
42+
}
43+
} else
44+
return state3;
45+
};
46+
public static final Function2<User, Request, Result> sign = (user, request) -> {
47+
int day = DateUtils.getDay();
48+
if (day != user.getUr()) {
49+
reg(day, user.getQq().longValue());
50+
int n = getRegNum(day);
51+
int s1 = 100;
52+
switch (n) {
53+
case 1:
54+
s1 = 220;
55+
break;
56+
case 2:
57+
s1 = 160;
58+
break;
59+
case 3:
60+
s1 = 120;
61+
break;
62+
}
63+
user.setPf(0);
64+
user.addP(s1);
65+
user.setUr(day);
66+
user.apply();
67+
return new Result(new Object[]{"http://q2.qlogo.cn/headimg_dl?dst_uin=" + user.getQq() + "&spec=100", n, s1}, 0);
68+
} else
69+
return state1;
70+
};
71+
public static final Function2<User, Request, Result> moraMethod = (user, request) -> {
72+
String str = request.getStr();
73+
int num = 0;
74+
try {
75+
num = Integer.parseInt(NumberUtils.findNumberFromString(str));
76+
if (mora.findMora(str, 0) == null) throw new Exception();
77+
} catch (Exception e) {
78+
return state5;
79+
}
80+
if (num < 5 || num > 2000)
81+
return new Result(new Object[]{5, 2000}, 4);
82+
if (user.getP() < num)
83+
return state3;
84+
mora m1 = mora.findMora(str, 0);
85+
mora m2 = mora.getRc();
86+
assert m1 != null;
87+
switch (m1.Reff(m2)) {
88+
case 0:
89+
return new Result(new Object[]{m2.getValue()}, 2);
90+
case 1:
91+
user.addP(num);
92+
user.apply();
93+
return new Result(new Object[]{m2.getValue(), num}, 1);
94+
case -1:
95+
user.addP(-num);
96+
user.apply();
97+
return new Result(new Object[]{m2.getValue(), num}, 0);
98+
}
99+
throw new RuntimeException();
100+
};
101+
102+
public static int getRegNum(int day) {
103+
File file = new File(Resource.conf.getPath(), "regs/" + DateUtils.getYear() + "/" + DateUtils.getMonth());
104+
if (!file.exists()) file.mkdirs();
105+
file = new File(file, day + ".list");
106+
if (!file.exists()) {
107+
try {
108+
file.createNewFile();
109+
} catch (IOException e) {
110+
e.printStackTrace();
111+
}
112+
}
113+
String[] strings = FileUtils.getStringsFromFile(file.getPath());
114+
return strings.length;
115+
}
116+
117+
public static void reg(int day, long q) {
118+
File file = new File(Resource.conf.getPath(), "regs/" + DateUtils.getYear() + "/" + DateUtils.getMonth());
119+
if (!file.exists()) file.mkdirs();
120+
file = new File(file, day + ".list");
121+
PrintWriter pw = null;
122+
try {
123+
pw = new PrintWriter(new FileOutputStream(file, true), true);
124+
} catch (FileNotFoundException e) {
125+
e.printStackTrace();
126+
}
127+
pw.println(q + "");
128+
pw.flush();
129+
pw.close();
130+
}
131+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cn.kloping.lsys.sc1;
2+
3+
import com.sun.istack.internal.NotNull;
4+
import net.mamoe.mirai.console.extension.PluginComponentStorage;
5+
import net.mamoe.mirai.console.plugin.PluginManager;
6+
import net.mamoe.mirai.console.plugin.jvm.JavaPlugin;
7+
import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescriptionBuilder;
8+
9+
import static cn.kloping.lsys.sc1.sc1.start;
10+
11+
12+
public class PluginMain extends JavaPlugin {
13+
public static final PluginMain INSTANCE = new PluginMain();
14+
15+
private PluginMain() {
16+
super(new JvmPluginDescriptionBuilder("cn.kloping.lsys.sco1.PluginMain", "0.1")
17+
.name("插件_7 Author => HRS LSys sco1 Loaded")
18+
.info("插件")
19+
.author("HRS")
20+
.build());
21+
}
22+
23+
@Override
24+
public void onLoad(@NotNull PluginComponentStorage $this$onLoad) {
25+
if (!Utils.isExits()) {
26+
getLogger().error("欲使用sco1插件 必须安装 Lsys 插件");
27+
getLogger().error("欲使用sco1插件 必须安装 Lsys 插件");
28+
getLogger().error("欲使用sco1插件 必须安装 Lsys 插件");
29+
PluginManager.INSTANCE.disablePlugin(INSTANCE);
30+
return;
31+
}
32+
try {
33+
start();
34+
} catch (Exception e) {
35+
e.printStackTrace();
36+
}
37+
}
38+
39+
@Override
40+
public void onEnable() {
41+
getLogger().info("");
42+
}
43+
}

0 commit comments

Comments
 (0)