diff --git a/pom.xml b/pom.xml
index aafdd40..c03d021 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.sadtech.vkbot
core
- 0.3-RELEASE
+ 0.4-SNAPSHOT
diff --git a/src/main/java/org/sadtech/vkbot/core/keyboard/ButtonKeyBoard.java b/src/main/java/org/sadtech/vkbot/core/keyboard/ButtonKeyBoard.java
index 350328e..d33d139 100644
--- a/src/main/java/org/sadtech/vkbot/core/keyboard/ButtonKeyBoard.java
+++ b/src/main/java/org/sadtech/vkbot/core/keyboard/ButtonKeyBoard.java
@@ -7,7 +7,7 @@ public class ButtonKeyBoard {
private String type = "text";
private String payload;
private String label;
- private ColorButton color = ColorButton.DEFAULT;
+ private ColorButton color = ColorButton.PRIMARY;
public ButtonKeyBoard() {
diff --git a/src/main/java/org/sadtech/vkbot/core/sender/MailSanderVk.java b/src/main/java/org/sadtech/vkbot/core/sender/MailSanderVk.java
index 1358b7d..82306ad 100644
--- a/src/main/java/org/sadtech/vkbot/core/sender/MailSanderVk.java
+++ b/src/main/java/org/sadtech/vkbot/core/sender/MailSanderVk.java
@@ -4,14 +4,11 @@ import com.vk.api.sdk.client.VkApiClient;
import com.vk.api.sdk.client.actors.GroupActor;
import com.vk.api.sdk.exceptions.ApiException;
import com.vk.api.sdk.exceptions.ClientException;
+import com.vk.api.sdk.queries.messages.MessagesSendQuery;
import org.sadtech.vkbot.core.VkConnect;
-import org.sadtech.vkbot.core.entity.Person;
public class MailSanderVk implements MailSandler {
- private Person person;
-
- private Integer idRecipient;
private VkApiClient vkApiClient;
private GroupActor groupActor;
@@ -19,34 +16,21 @@ public class MailSanderVk implements MailSandler {
this.vkApiClient = vkConnect.getVkApiClient();
this.groupActor = vkConnect.getGroupActor();
}
-
- public MailSanderVk(Person person, VkConnect vkConnect) {
- this.person = person;
- this.vkApiClient = vkConnect.getVkApiClient();
- this.groupActor = vkConnect.getGroupActor();
- }
-
- public void setIdRecipient(Integer idRecipient) {
- this.idRecipient = idRecipient;
- }
-
- public void setPerson(Person person) {
- idRecipient = person.getId();
- }
-
@Override
- public void send(String text, String keyBoard) {
- try {
- vkApiClient.messages().send(groupActor).peerId(idRecipient).keyboard(keyBoard).message(text).execute();
- } catch (ApiException | ClientException e) {
- e.printStackTrace();
+ public void send(MailSend mailSend) {
+ MessagesSendQuery messages = vkApiClient.messages().send(groupActor).peerId(mailSend.getIdRecipient());
+ if (mailSend.getMessage()!=null) {
+ messages.message(mailSend.getMessage());
+ }
+ if (mailSend.getKeyboard()!=null) {
+ messages.keyboard(mailSend.getKeyboard());
+ }
+ if (mailSend.getLat()!=null && mailSend.getaLong()!=null) {
+ messages.lat(mailSend.getLat()).lng(mailSend.getaLong());
}
- }
- @Override
- public void send(String text) {
try {
- vkApiClient.messages().send(groupActor).userId(idRecipient).message(text).execute();
+ messages.execute();
} catch (ApiException | ClientException e) {
e.printStackTrace();
}
diff --git a/src/main/java/org/sadtech/vkbot/core/sender/MailSandler.java b/src/main/java/org/sadtech/vkbot/core/sender/MailSandler.java
index a7e569a..54989e0 100644
--- a/src/main/java/org/sadtech/vkbot/core/sender/MailSandler.java
+++ b/src/main/java/org/sadtech/vkbot/core/sender/MailSandler.java
@@ -1,13 +1,7 @@
package org.sadtech.vkbot.core.sender;
-import org.sadtech.vkbot.core.entity.Person;
-
public interface MailSandler {
- void send(String text);
-
- void setPerson(Person person);
-
- void send(String text, String keyBoard);
+ void send(MailSend mailSend);
}
diff --git a/src/main/java/org/sadtech/vkbot/core/sender/MailSend.java b/src/main/java/org/sadtech/vkbot/core/sender/MailSend.java
new file mode 100644
index 0000000..aa98d1c
--- /dev/null
+++ b/src/main/java/org/sadtech/vkbot/core/sender/MailSend.java
@@ -0,0 +1,54 @@
+package org.sadtech.vkbot.core.sender;
+
+public class MailSend {
+
+ private String message;
+ private String keyboard;
+ private Integer idRecipient;
+ private Float lat;
+ private Float aLong;
+
+ public MailSend() {
+
+ }
+
+ public String getKeyboard() {
+ return keyboard;
+ }
+
+ public void setKeyboard(String keyboard) {
+ this.keyboard = keyboard;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public Integer getIdRecipient() {
+ return idRecipient;
+ }
+
+ public void setIdRecipient(Integer idRecipient) {
+ this.idRecipient = idRecipient;
+ }
+
+ public Float getLat() {
+ return lat;
+ }
+
+ public void setLat(Float lat) {
+ this.lat = lat;
+ }
+
+ public Float getaLong() {
+ return aLong;
+ }
+
+ public void setaLong(Float aLong) {
+ this.aLong = aLong;
+ }
+}