Переход на Gson вместо непонятной Json библиотеки
This commit is contained in:
parent
c50ce8cd40
commit
a92d71ef3e
6
pom.xml
6
pom.xml
@ -32,7 +32,6 @@
|
||||
<gson.ver>2.8.5</gson.ver>
|
||||
<vksdk.ver>0.5.13-SNAPSHOT</vksdk.ver>
|
||||
<log4j.ver>1.2.17</log4j.ver>
|
||||
<json.ver>20180813</json.ver>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -51,11 +50,6 @@
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.ver}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>${json.ver}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -20,7 +20,7 @@ public class MailSubscriber implements EventSubscribe<JsonObject>, EventDistribu
|
||||
private MailService mailService;
|
||||
|
||||
private Set<Integer> admins = new HashSet<>();
|
||||
private Map<String, EventSubscribe> eventDistributionMap = new HashMap<>();
|
||||
private Map<String, EventSubscribe<Message>> eventDistributionMap = new HashMap<>();
|
||||
|
||||
public MailSubscriber(EventDistributable eventDistributable, MailService mailService) {
|
||||
this.mailService = mailService;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package org.sadtech.vkbot.core.distribution.impl;
|
||||
|
||||
import com.vk.api.sdk.objects.messages.Message;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.sadtech.vkbot.core.distribution.EventSubscribe;
|
||||
import org.sadtech.vkbot.core.entity.Mail;
|
||||
import org.sadtech.vkbot.core.service.handlers.MailService;
|
||||
|
||||
public class TerminalSubscriber implements EventSubscribe<Mail> {
|
||||
public class TerminalSubscriber implements EventSubscribe<Message> {
|
||||
|
||||
public static final Logger log = Logger.getLogger(TerminalSubscriber.class);
|
||||
|
||||
@ -25,7 +25,7 @@ public class TerminalSubscriber implements EventSubscribe<Mail> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Mail object) {
|
||||
public void update(Message object) {
|
||||
log.info("Сообщение отправленно на добавление в репозиторий команд");
|
||||
mailService.add(object);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.sadtech.vkbot.core.keyboard;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class ButtonKeyBoard {
|
||||
|
||||
@ -20,18 +20,18 @@ public class ButtonKeyBoard {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public JSONObject getButton() {
|
||||
JSONObject newButton = new JSONObject();
|
||||
newButton.put("color", color.toString().toLowerCase());
|
||||
newButton.put("action", generateAction());
|
||||
public JsonObject getButton() {
|
||||
JsonObject newButton = new JsonObject();
|
||||
newButton.addProperty("color", color.toString().toLowerCase());
|
||||
newButton.add("action", generateAction());
|
||||
return newButton;
|
||||
}
|
||||
|
||||
private JSONObject generateAction() {
|
||||
JSONObject action = new JSONObject();
|
||||
action.put("type", type);
|
||||
action.put("payload", payload);
|
||||
action.put("label", label);
|
||||
private JsonObject generateAction() {
|
||||
JsonObject action = new JsonObject();
|
||||
action.addProperty("type", type);
|
||||
action.addProperty("payload", payload);
|
||||
action.addProperty("label", label);
|
||||
return action;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.sadtech.vkbot.core.keyboard;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -24,16 +24,16 @@ public class KeyBoard {
|
||||
this.oneTime = oneTime;
|
||||
}
|
||||
|
||||
public JSONObject getKeyboard() {
|
||||
JSONObject keyboard = new JSONObject();
|
||||
keyboard.put("one_time", oneTime);
|
||||
public JsonObject getKeyboard() {
|
||||
JsonObject keyboard = new JsonObject();
|
||||
keyboard.addProperty("one_time", oneTime);
|
||||
|
||||
JSONArray menuLine = new JSONArray();
|
||||
JsonArray menuLine = new JsonArray();
|
||||
for (LineKeyBoard lineKeyboard : lineKeyBoards) {
|
||||
menuLine.put(lineKeyboard.getLine());
|
||||
menuLine.add(lineKeyboard.getLine());
|
||||
}
|
||||
|
||||
keyboard.put("buttons", menuLine);
|
||||
keyboard.add("buttons", menuLine);
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.sadtech.vkbot.core.keyboard;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import com.google.gson.JsonArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -17,10 +17,10 @@ public class LineKeyBoard {
|
||||
this.buttonKeyBoards = buttonKeyBoards;
|
||||
}
|
||||
|
||||
public JSONArray getLine() {
|
||||
JSONArray line = new JSONArray();
|
||||
public JsonArray getLine() {
|
||||
JsonArray line = new JsonArray();
|
||||
for (ButtonKeyBoard buttonKeyBoard : buttonKeyBoards) {
|
||||
line.put(buttonKeyBoard.getButton());
|
||||
line.add(buttonKeyBoard.getButton());
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user