|
@@ -0,0 +1,64 @@
|
|
1
|
+package kr.co.swh.lecture.opensource.discord.project;
|
|
2
|
+
|
|
3
|
+import java.io.IOException;
|
|
4
|
+import java.util.ArrayList;
|
|
5
|
+import java.util.Arrays;
|
|
6
|
+import java.util.List;
|
|
7
|
+
|
|
8
|
+import javax.security.auth.login.LoginException;
|
|
9
|
+
|
|
10
|
+import org.apache.http.HttpResponse;
|
|
11
|
+import org.apache.http.client.methods.HttpGet;
|
|
12
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
13
|
+import org.apache.http.impl.client.HttpClients;
|
|
14
|
+import org.apache.http.util.EntityUtils;
|
|
15
|
+
|
|
16
|
+import com.google.gson.Gson;
|
|
17
|
+
|
|
18
|
+import net.dv8tion.jda.api.AccountType;
|
|
19
|
+import net.dv8tion.jda.api.JDA;
|
|
20
|
+import net.dv8tion.jda.api.JDABuilder;
|
|
21
|
+import net.dv8tion.jda.api.OnlineStatus;
|
|
22
|
+
|
|
23
|
+public class SendJDA {
|
|
24
|
+
|
|
25
|
+ public static JDA jda;
|
|
26
|
+ public static void main(String[] args) {
|
|
27
|
+ // TODO Auto-generated method stub
|
|
28
|
+ List<SentimentalDic> dicList = initDatas();
|
|
29
|
+ JDABuilder jb = new JDABuilder(AccountType.BOT);
|
|
30
|
+ jb.setAutoReconnect(true);
|
|
31
|
+ jb.setStatus(OnlineStatus.DO_NOT_DISTURB);
|
|
32
|
+ jb.setToken("NjYzMjgzODYxMTUyNTk1OTkz.XhGR3g.GubjRZ-9njci3CUCoasIFj02mmU");
|
|
33
|
+ jb.addEventListeners(new TListener(dicList));
|
|
34
|
+
|
|
35
|
+ try {
|
|
36
|
+ jda = jb.build();
|
|
37
|
+ } catch (LoginException e) {
|
|
38
|
+ // TODO Auto-generated catch block
|
|
39
|
+ e.printStackTrace();
|
|
40
|
+ }
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ public static List<SentimentalDic> initDatas() {
|
|
44
|
+ Gson gson = new Gson();
|
|
45
|
+ List<SentimentalDic> dicList = new ArrayList<SentimentalDic>();
|
|
46
|
+ CloseableHttpClient client = HttpClients.createDefault();
|
|
47
|
+ HttpResponse response = null;
|
|
48
|
+ String responseString = "";
|
|
49
|
+ HttpGet requestGet = new HttpGet("https://raw.githubusercontent.com/park1200656/KnuSentiLex/master/data/SentiWord_info.json");
|
|
50
|
+ try {
|
|
51
|
+ response = client.execute(requestGet);
|
|
52
|
+ responseString = EntityUtils.toString(response.getEntity());
|
|
53
|
+ SentimentalDic[] value = gson.fromJson(responseString, SentimentalDic[].class);
|
|
54
|
+ for(SentimentalDic dic : value) {
|
|
55
|
+ System.out.println(dic.getWord());
|
|
56
|
+ }
|
|
57
|
+ dicList.addAll(Arrays.asList(value));
|
|
58
|
+ } catch (IOException e2) {
|
|
59
|
+ // TODO Auto-generated catch block
|
|
60
|
+ e2.printStackTrace();
|
|
61
|
+ }
|
|
62
|
+ return dicList;
|
|
63
|
+ }
|
|
64
|
+}
|