From aab0f6b0756f5fce9f3b64db98b9f49cccd55cfd Mon Sep 17 00:00:00 2001 From: Mark Struchkov Date: Mon, 13 May 2019 20:53:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=B2=D0=B5=D0=BB=20=D0=BA?= =?UTF-8?q?=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=B2=D0=B5=D1=80=D1=81?= =?UTF-8?q?=D0=B8=D0=B8=20SDK=20VK=201.0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/sadtech/vkbot/core/VkApi.java | 4 +--- .../org/sadtech/vkbot/core/sender/MailSenderVk.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) 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; + } }