diff --git a/src/main/java/org/sadtech/vkbot/core/VkApi.java b/src/main/java/org/sadtech/vkbot/core/VkApi.java index 08a21bb..eebb050 100644 --- a/src/main/java/org/sadtech/vkbot/core/VkApi.java +++ b/src/main/java/org/sadtech/vkbot/core/VkApi.java @@ -32,9 +32,7 @@ public class VkApi { try { List temp = vk.users().get(actor).userIds(String.valueOf(id)).execute(); JsonParser parser = new JsonParser(); - JsonObject object = parser.parse(temp.get(0).toString().substring(15)).getAsJsonObject(); - object.add("last_name", object.get("lastName")); - object.add("first_name", object.get("firstName")); + JsonObject object = parser.parse(temp.get(0).toString()).getAsJsonObject(); userMin = gson.fromJson(object, UserMin.class); } catch (ApiException | ClientException e) { log.error(e); diff --git a/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java b/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java index d5fd01b..1ea63a4 100644 --- a/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java +++ b/src/main/java/org/sadtech/vkbot/core/sender/MailSenderVk.java @@ -11,6 +11,8 @@ import org.sadtech.bot.core.sender.Sent; import org.sadtech.vkbot.core.VkConnect; import org.sadtech.vkbot.core.VkInsertData; +import java.util.concurrent.ThreadLocalRandom; + public class MailSenderVk implements Sent { private static final Logger log = Logger.getLogger(MailSenderVk.class); @@ -28,7 +30,7 @@ public class MailSenderVk implements Sent { @Override public void send(Integer idPerson, String message) { - sendMessage(vkApiClient.messages().send(groupActor).peerId(idPerson).message(message)); + sendMessage(vkApiClient.messages().send(groupActor).peerId(idPerson).message(message).randomId(ThreadLocalRandom.current().nextInt(0, Integer.MAX_VALUE))); } @Override @@ -39,7 +41,7 @@ public class MailSenderVk implements Sent { //FIXME: Пофиксить клавиатуры private MessagesSendQuery createMessage(BoxAnswer boxAnswer, Integer peerId) { - MessagesSendQuery messages = vkApiClient.messages().send(groupActor).peerId(peerId).message(vkInsertData.insertWords(boxAnswer.getMessage(), peerId)); + MessagesSendQuery messages = vkApiClient.messages().send(groupActor).peerId(peerId).message(vkInsertData.insertWords(boxAnswer.getMessage(), peerId)).randomId(ThreadLocalRandom.current().nextInt(0, Integer.MAX_VALUE)); if (boxAnswer.getKeyboard() != null) { // messages.keyboard(boxAnswer.getKeyboard()); } else { @@ -65,4 +67,8 @@ public class MailSenderVk implements Sent { log.error(e); } } + + private Integer reandomId() { + return null; + } }