21
21
import java .util .concurrent .ExecutorService ;
22
22
import java .util .concurrent .Executors ;
23
23
24
+ import static cn .kloping .lsys .utils .MessageUtils .createImageInGroup ;
25
+
24
26
public class Loader {
25
27
public static Conf conf = new Conf (0 , 12 );
26
28
@@ -54,7 +56,7 @@ public class Loader {
54
56
}
55
57
String name = request .getStr ().substring (request .getOStr ().indexOf ("." ));
56
58
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" )));
58
60
startCd ();
59
61
ForwardMessageBuilder builder = new ForwardMessageBuilder (request .getEvent ().getSubject ());
60
62
long id = request .getEvent ().getBot ().getId ();
@@ -101,7 +103,7 @@ private static void startCd() {
101
103
}
102
104
String name = request .getStr ().substring (request .getOStr ().indexOf ("." ));
103
105
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" )));
105
107
String picUrl = jo .getJSONArray ("data" ).getString (0 );
106
108
startCd ();
107
109
return new Result (new Object []{picUrl }, 0 );
@@ -119,7 +121,7 @@ private static void startCd() {
119
121
}
120
122
String name = request .getStr ().substring (request .getOStr ().indexOf ("." ));
121
123
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" )));
123
125
startCd ();
124
126
ForwardMessageBuilder builder = new ForwardMessageBuilder (request .getEvent ().getSubject ());
125
127
long id = request .getEvent ().getBot ().getId ();
@@ -144,27 +146,27 @@ private static void startCd() {
144
146
};
145
147
146
148
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
+ // }
168
170
169
171
public static final Runnable runnable = () -> {
170
172
if (!Resource .conf .getInvokeGroups ().containsKey ("getPic" ))
@@ -176,7 +178,7 @@ public static void loadConf() {
176
178
}
177
179
178
180
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 );
180
182
}
181
183
182
184
public static void load () {
0 commit comments