Compare commits

...

4 Commits

Author SHA1 Message Date
2713cd8246
[maven-release-plugin] prepare for next development iteration
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-29 01:21:19 +03:00
bcfa12d7f7
[maven-release-plugin] prepare release v.0.0.54 2023-03-29 01:21:19 +03:00
183cc4a203
godfather 0.0.55 2023-03-29 01:20:27 +03:00
19c75c4c49
Доработка клавиатур 2023-03-29 01:20:00 +03:00
38 changed files with 311 additions and 183 deletions

View File

@ -4,7 +4,7 @@
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-bot</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
@ -38,7 +38,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<godfather.core.ver>0.0.55-SNAPSHOT</godfather.core.ver>
<godfather.core.ver>0.0.55</godfather.core.ver>
<!-- https://mvnrepository.com/artifact/org.telegram/telegrambots -->
<telegrambots.ver>6.3.0</telegrambots.ver>

View File

@ -4,7 +4,7 @@
<parent>
<artifactId>telegram-bot</artifactId>
<groupId>dev.struchkov.godfather.telegram</groupId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-consumer</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-consumer</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-consumer-main</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-consumer</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-consumer-quarkus</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-consumer</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-consumer-simple</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<artifactId>telegram-bot</artifactId>
<groupId>dev.struchkov.godfather.telegram</groupId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-context</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-context</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-context-main</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-context</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-context-quarkus</artifactId>

View File

@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>telegram-context</artifactId>
<groupId>dev.struchkov.godfather.telegram</groupId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-context-simple</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-bot</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<modules>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-core</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-core-main</artifactId>

View File

@ -2,7 +2,6 @@ package dev.struchkov.godfather.telegram.main.core.util;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton;
import dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoard;
import dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine;
import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard;
@ -24,21 +23,19 @@ public final class InlineKeyBoards {
/**
* Возвращает клавиатуру формата 1х2, с кнопками "Да | Нет"
*
* @return {@link SimpleKeyBoard}
*/
public static SimpleKeyBoardLine lineYesOrNo() {
return simpleLine(YES_BUTTON, NO_BUTTON);
public static InlineKeyBoard lineYesOrNo() {
return InlineKeyBoard.inlineKeyBoard(simpleLine(YES_BUTTON, NO_BUTTON));
}
/**
* Возвращает клавиатуру формата 1хN, где N - это количество элементов в переданном списке
*
* @param labelButtons Список названий для кнопок
* @return {@link SimpleKeyBoard}
* @return {@link InlineKeyBoard}
*/
public static InlineKeyBoard verticalMenuString(List<String> labelButtons) {
final InlineKeyBoard.Builder keyBoard = InlineKeyBoard.builder();
final InlineKeyBoard.InlineKeyBoardBuilder keyBoard = InlineKeyBoard.builder();
for (String labelButton : labelButtons) {
keyBoard.line(simpleLine(simpleButton(labelButton, labelButton)));
}
@ -49,7 +46,7 @@ public final class InlineKeyBoards {
* Возвращает клавиатуру формата 1хN, где N - это количество элементов в переданном списке
*
* @param labelButton Список названий для кнопок
* @return {@link SimpleKeyBoard}
* @return {@link InlineKeyBoard}
*/
public static InlineKeyBoard verticalMenuString(String... labelButton) {
return verticalMenuString(Arrays.asList(labelButton));
@ -59,7 +56,7 @@ public final class InlineKeyBoards {
* Возвращает клавиатуру формата 2х(N/2), где N - это количество элементов в переданном списке
*
* @param labelButton Список названий для кнопок
* @return {@link SimpleKeyBoard}
* @return {@link InlineKeyBoard}
*/
public static InlineKeyBoard verticalDuoMenuString(String... labelButton) {
return verticalDuoMenuString(Arrays.asList(labelButton));
@ -69,12 +66,12 @@ public final class InlineKeyBoards {
* Возвращает клавиатуру формата 2х(N/2), где N - это количество элементов в переданном списке
*
* @param labelButton Список названий для кнопок
* @return {@link SimpleKeyBoard}
* @return {@link InlineKeyBoard}
*/
public static InlineKeyBoard verticalDuoMenuString(List<String> labelButton) {
final InlineKeyBoard.Builder keyBoard = InlineKeyBoard.builder();
final InlineKeyBoard.InlineKeyBoardBuilder keyBoard = InlineKeyBoard.builder();
boolean flag = true;
SimpleKeyBoardLine.Builder keyBoardLine = SimpleKeyBoardLine.builder();
SimpleKeyBoardLine.SimpleKeyBoardLineBuilder keyBoardLine = SimpleKeyBoardLine.builder();
for (int i = 0; i <= labelButton.size() - 1; i++) {
String label = labelButton.get(i);
keyBoardLine.button(simpleButton(label));
@ -93,9 +90,9 @@ public final class InlineKeyBoards {
return keyBoard.build();
}
public static void verticalDuoMenu(InlineKeyBoard.Builder builder, List<? extends KeyBoardButton> buttons) {
public static void verticalDuoMenu(InlineKeyBoard.InlineKeyBoardBuilder builder, List<? extends KeyBoardButton> buttons) {
boolean flag = true;
SimpleKeyBoardLine.Builder keyBoardLine = SimpleKeyBoardLine.builder();
SimpleKeyBoardLine.SimpleKeyBoardLineBuilder keyBoardLine = SimpleKeyBoardLine.builder();
for (int i = 0; i <= buttons.size() - 1; i++) {
keyBoardLine.button(buttons.get(i));
if (flag) {
@ -113,7 +110,7 @@ public final class InlineKeyBoards {
}
public static InlineKeyBoard verticalDuoMenu(List<? extends KeyBoardButton> buttons) {
final InlineKeyBoard.Builder keyBoard = InlineKeyBoard.builder();
final InlineKeyBoard.InlineKeyBoardBuilder keyBoard = InlineKeyBoard.builder();
verticalDuoMenu(keyBoard, buttons);
return keyBoard.build();
}
@ -126,10 +123,10 @@ public final class InlineKeyBoards {
* Возвращает клавиатуру формата 1xN сформированную из списка кнопок, где N - количество кнопок в списке
*
* @param buttons Список кнопок
* @return {@link SimpleKeyBoard}
* @return {@link InlineKeyBoard}
*/
public static InlineKeyBoard verticalMenuButton(KeyBoardButton... buttons) {
final InlineKeyBoard.Builder keyBoard = InlineKeyBoard.builder();
final InlineKeyBoard.InlineKeyBoardBuilder keyBoard = InlineKeyBoard.builder();
for (KeyBoardButton simpleButton : buttons) {
keyBoard.line(simpleLine(simpleButton));
}

View File

@ -0,0 +1,112 @@
package dev.struchkov.godfather.telegram.main.core.util;
import dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton;
import dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine;
import dev.struchkov.godfather.telegram.domain.keyboard.MarkupKeyBoard;
import java.util.Arrays;
import java.util.List;
/**
* Используется для быстрого создания клавиаутр {@link MarkupKeyBoard}.
*
* @author upagge [08/07/2019]
*/
public class SimpleKeyBoards {
public static final SimpleButton YES_BUTTON = SimpleButton.simpleButton("Да", "{\"button\": \"yes\"}");
public static final SimpleButton NO_BUTTON = SimpleButton.simpleButton("Нет", "{\"button\": \"no\"}");
private SimpleKeyBoards() {
throw new IllegalStateException();
}
/**
* Возвращает клавиатуру формата 1х2, с кнопками "Да | Нет"
*
* @return {@link MarkupKeyBoard}
*/
public static MarkupKeyBoard keyBoardYesNo() {
return MarkupKeyBoard.builder().line(
SimpleKeyBoardLine.builder().button(YES_BUTTON).button(NO_BUTTON).build()
).build();
}
/**
* Возвращает клавиатуру формата 1хN, где N - это количество элементов в переданном списке
*
* @param labelButtons Список названий для кнопок
* @return {@link MarkupKeyBoard}
*/
public static MarkupKeyBoard verticalMenuString(List<String> labelButtons) {
final MarkupKeyBoard.MarkupKeyBoardBuilder keyBoard = MarkupKeyBoard.builder();
for (String labelButton : labelButtons) {
final SimpleButton simpleButton = SimpleButton.simpleButton(labelButton, "{\"button\": \"" + labelButton + "\"}");
keyBoard.line(SimpleKeyBoardLine.builder().button(simpleButton).build());
}
return keyBoard.build();
}
/**
* Возвращает клавиатуру формата 1хN, где N - это количество элементов в переданном списке
*
* @param labelButton Список названий для кнопок
* @return {@link MarkupKeyBoard}
*/
public static MarkupKeyBoard verticalMenuString(String... labelButton) {
return verticalMenuString(Arrays.asList(labelButton));
}
/**
* Возвращает клавиатуру формата 2х(N/2), где N - это количество элементов в переданном списке
*
* @param labelButton Список названий для кнопок
* @return {@link MarkupKeyBoard}
*/
public static MarkupKeyBoard verticalDuoMenuString(String... labelButton) {
return verticalDuoMenuString(Arrays.asList(labelButton));
}
/**
* Возвращает клавиатуру формата 2х(N/2), где N - это количество элементов в переданном списке
*
* @param labelButton Список названий для кнопок
* @return {@link MarkupKeyBoard}
*/
public static MarkupKeyBoard verticalDuoMenuString(List<String> labelButton) {
final MarkupKeyBoard.MarkupKeyBoardBuilder keyBoard = MarkupKeyBoard.builder();
boolean flag = true;
SimpleKeyBoardLine.SimpleKeyBoardLineBuilder keyBoardLine = SimpleKeyBoardLine.builder();
for (int i = 0; i <= labelButton.size() - 1; i++) {
String label = labelButton.get(i);
keyBoardLine.button(SimpleButton.simpleButton(label));
if (flag) {
if (i == labelButton.size() - 1) {
keyBoard.line(keyBoardLine.build());
} else {
flag = false;
}
} else {
keyBoard.line(keyBoardLine.build());
keyBoardLine = SimpleKeyBoardLine.builder();
flag = true;
}
}
return keyBoard.build();
}
/**
* Возвращает клавиатуру формата 1xN сформированную из списка кнопок, где N - количество кнопок в списке
*
* @param simpleButtons Список кнопок
* @return {@link MarkupKeyBoard}
*/
public static MarkupKeyBoard verticalMenuButton(List<SimpleButton> simpleButtons) {
final MarkupKeyBoard.MarkupKeyBoardBuilder keyBoard = MarkupKeyBoard.builder();
for (SimpleButton simpleButton : simpleButtons) {
keyBoard.line(SimpleKeyBoardLine.builder().button(simpleButton).build());
}
return keyBoard.build();
}
}

View File

@ -4,7 +4,7 @@
<parent>
<artifactId>telegram-core</artifactId>
<groupId>dev.struchkov.godfather.telegram</groupId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-core-quarkus</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-core</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-core-simple</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-bot</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-domain</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-domain</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-domain-main</artifactId>

View File

@ -48,7 +48,7 @@ public final class UnitPaginationUtil {
* @param countElements - общее количество элементов которое может вернуть запрос
*/
public static Optional<KeyBoardLine> navigableLine(Integer currentOffset, Integer countElements) {
final SimpleKeyBoardLine.Builder lineBuilder = SimpleKeyBoardLine.builder();
final SimpleKeyBoardLine.SimpleKeyBoardLineBuilder lineBuilder = SimpleKeyBoardLine.builder();
final Optional<KeyBoardButton> optPrevButton = getPrevPageButton(currentOffset);
final Optional<KeyBoardButton> optNextButton = getNextPageButton(currentOffset, countElements);

View File

@ -0,0 +1,46 @@
package dev.struchkov.godfather.telegram.domain.deser;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton;
import dev.struchkov.godfather.telegram.domain.keyboard.button.ContactButton;
import dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton;
import dev.struchkov.godfather.telegram.domain.keyboard.button.WebAppButton;
import java.io.IOException;
public class TelegramKeyboardButtonDeserializer extends StdDeserializer<KeyBoardButton> {
public TelegramKeyboardButtonDeserializer() {
this(null);
}
public TelegramKeyboardButtonDeserializer(Class<?> vc) {
super(vc);
}
@Override
public KeyBoardButton deserialize(JsonParser parser, DeserializationContext context) throws IOException {
final JsonNode node = parser.getCodec().readTree(parser);
final String typeKeyBoard = node.get("type").asText();
switch (typeKeyBoard) {
case "SIMPLE" -> {
return parser.getCodec().treeToValue(node, SimpleButton.class);
}
case "CONTACT" -> {
return parser.getCodec().treeToValue(node, ContactButton.class);
}
case "URL" -> {
return parser.getCodec().treeToValue(node, UrlButton.class);
}
case "WEB_APP" -> {
return parser.getCodec().treeToValue(node, WebAppButton.class);
}
}
throw new RuntimeException();
}
}

View File

@ -0,0 +1,38 @@
package dev.struchkov.godfather.telegram.domain.deser;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoard;
import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard;
import dev.struchkov.godfather.telegram.domain.keyboard.MarkupKeyBoard;
import java.io.IOException;
public class TelegramKeyboardDeserializer extends StdDeserializer<KeyBoard> {
public TelegramKeyboardDeserializer() {
this(null);
}
public TelegramKeyboardDeserializer(Class<?> vc) {
super(vc);
}
@Override
public KeyBoard deserialize(JsonParser parser, DeserializationContext context) throws IOException {
final JsonNode node = parser.getCodec().readTree(parser);
final String typeKeyBoard = node.get("type").asText();
switch (typeKeyBoard) {
case "INLINE" -> {
return parser.getCodec().treeToValue(node, InlineKeyBoard.class);
}
case "MARKUP" -> {
return parser.getCodec().treeToValue(node, MarkupKeyBoard.class);
}
}
throw new RuntimeException();
}
}

View File

@ -0,0 +1,28 @@
package dev.struchkov.godfather.telegram.domain.deser;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardLine;
import dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine;
import java.io.IOException;
public class TelegramKeyboardLineDeserializer extends StdDeserializer<KeyBoardLine> {
public TelegramKeyboardLineDeserializer() {
this(null);
}
public TelegramKeyboardLineDeserializer(Class<?> vc) {
super(vc);
}
@Override
public KeyBoardLine deserialize(JsonParser parser, DeserializationContext context) throws IOException {
final JsonNode node = parser.getCodec().readTree(parser);
return parser.getCodec().treeToValue(node, SimpleKeyBoardLine.class);
}
}

View File

@ -3,38 +3,32 @@ package dev.struchkov.godfather.telegram.domain.keyboard;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoard;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardLine;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import java.util.ArrayList;
import java.util.List;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class InlineKeyBoard implements KeyBoard {
public static final String TYPE = "INLINE";
@Singular
protected List<KeyBoardLine> lines;
public InlineKeyBoard(List<KeyBoardLine> lines) {
this.lines = lines;
}
private InlineKeyBoard(Builder builder) {
this.lines = builder.lines;
}
public static Builder builder() {
return new Builder();
}
public static InlineKeyBoard inlineKeyBoard(KeyBoardLine... keyBoardLine) {
final Builder builder = builder();
final InlineKeyBoardBuilder builder = builder();
for (KeyBoardLine boardLine : keyBoardLine) {
builder.line(boardLine);
}
@ -50,27 +44,4 @@ public class InlineKeyBoard implements KeyBoard {
return TYPE;
}
public static final class Builder {
private List<KeyBoardLine> lines = new ArrayList<>();
private Builder() {
}
public Builder lines(List<KeyBoardLine> val) {
lines = val;
return this;
}
public Builder line(KeyBoardLine val) {
lines.add(val);
return this;
}
public InlineKeyBoard build() {
return new InlineKeyBoard(this);
}
}
}

View File

@ -1,19 +1,34 @@
package dev.struchkov.godfather.telegram.domain.keyboard;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoard;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardLine;
import dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoard;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
public class MarkupKeyBoard extends SimpleKeyBoard {
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class MarkupKeyBoard implements KeyBoard {
public static final String TYPE = "MARKUP";
private static final MarkupKeyBoard EMPTY = new MarkupKeyBoard();
@Singular
protected List<KeyBoardLine> lines;
/**
* Скрыть меню после ответа или нет.
*/
@ -26,19 +41,8 @@ public class MarkupKeyBoard extends SimpleKeyBoard {
private String inputFieldPlaceholder;
public MarkupKeyBoard() {
super(Collections.emptyList());
}
private MarkupKeyBoard(Builder builder) {
super(builder.lines);
oneTime = builder.oneTime;
resizeKeyboard = builder.resizeKeyboard;
inputFieldPlaceholder = builder.inputFieldPlaceholder;
}
public static MarkupKeyBoard markupKeyBoard(KeyBoardLine... lines) {
final Builder builder = new Builder();
final MarkupKeyBoardBuilder builder = new MarkupKeyBoardBuilder();
for (KeyBoardLine line : lines) {
builder.line(line);
}
@ -46,33 +50,17 @@ public class MarkupKeyBoard extends SimpleKeyBoard {
}
public static MarkupKeyBoard markupKeyBoard(KeyBoardButton... buttons) {
final Builder builder = new Builder();
final MarkupKeyBoardBuilder builder = new MarkupKeyBoardBuilder();
for (KeyBoardButton button : buttons) {
builder.line(simpleLine(button));
}
return builder.build();
}
public static Builder markupBuilder() {
return new Builder();
}
public static MarkupKeyBoard empty() {
return EMPTY;
}
public boolean isResizeKeyboard() {
return resizeKeyboard;
}
public String getInputFieldPlaceholder() {
return inputFieldPlaceholder;
}
public boolean isOneTime() {
return oneTime;
}
@Override
public String getType() {
return TYPE;
@ -86,42 +74,4 @@ public class MarkupKeyBoard extends SimpleKeyBoard {
return !lines.isEmpty();
}
public static final class Builder {
private List<KeyBoardLine> lines = new ArrayList<>();
private boolean oneTime = true;
private boolean resizeKeyboard;
private String inputFieldPlaceholder;
private Builder() {
}
public Builder lines(List<KeyBoardLine> val) {
lines = val;
return this;
}
public Builder line(KeyBoardLine val) {
lines.add(val);
return this;
}
public Builder oneTime(boolean val) {
oneTime = val;
return this;
}
public Builder resizeKeyboard(boolean val) {
resizeKeyboard = val;
return this;
}
public Builder inputFieldPlaceholder(String val) {
inputFieldPlaceholder = val;
return this;
}
public MarkupKeyBoard build() {
return new MarkupKeyBoard(this);
}
}
}

View File

@ -1,6 +1,9 @@
package dev.struchkov.godfather.telegram.domain.keyboard.button;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -13,17 +16,15 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
*/
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class ContactButton implements KeyBoardButton {
public static final String TYPE = "CONTACT";
private String label;
private ContactButton(String label) {
this.label = label;
}
public static ContactButton contactButton(String label) {
isNotNull(label, nullPointer("label"));
return new ContactButton(label);

View File

@ -1,6 +1,9 @@
package dev.struchkov.godfather.telegram.domain.keyboard.button;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -9,7 +12,9 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class UrlButton implements KeyBoardButton {
public static final String TYPE = "URL";
@ -17,11 +22,6 @@ public class UrlButton implements KeyBoardButton {
private String label;
private String url;
public UrlButton(String label, String url) {
this.label = label;
this.url = url;
}
public static UrlButton urlButton(String label, String url) {
isNotNull(label, url);
return new UrlButton(label, url);

View File

@ -1,6 +1,9 @@
package dev.struchkov.godfather.telegram.domain.keyboard.button;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -9,7 +12,9 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class WebAppButton implements KeyBoardButton {
public static final String TYPE = "WEB_APP";
@ -17,11 +22,6 @@ public class WebAppButton implements KeyBoardButton {
private String label;
private String url;
private WebAppButton(String label, String url) {
this.label = label;
this.url = url;
}
public static WebAppButton webAppButton(String label, String url) {
isNotNull(label, url);
return new WebAppButton(label, url);

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-domain</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-domain-quarkus</artifactId>

View File

@ -122,7 +122,7 @@ public class UnitPage<T> {
final List<KeyBoardLine> lines = elements.stream()
.map(function)
.toList();
final InlineKeyBoard.Builder builder = InlineKeyBoard.builder();
final InlineKeyBoard.InlineKeyBoardBuilder builder = InlineKeyBoard.builder();
lines.forEach(builder::line);
if (!removeDefaultNavigableLine) {

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-domain</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-domain-simple</artifactId>

View File

@ -122,7 +122,7 @@ public class UnitPage<T> {
final List<KeyBoardLine> lines = elements.stream()
.map(function)
.toList();
final InlineKeyBoard.Builder builder = InlineKeyBoard.builder();
final InlineKeyBoard.InlineKeyBoardBuilder builder = InlineKeyBoard.builder();
lines.forEach(builder::line);
if (!removeDefaultNavigableLine) {

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-bot</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-sender</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-sender</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-sender-main</artifactId>

View File

@ -4,7 +4,6 @@ import dev.struchkov.godfather.main.domain.keyboard.KeyBoard;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardLine;
import dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton;
import dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoard;
import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard;
import dev.struchkov.godfather.telegram.domain.keyboard.MarkupKeyBoard;
import dev.struchkov.godfather.telegram.domain.keyboard.button.ContactButton;
@ -42,24 +41,11 @@ public final class KeyBoardConvert {
case MarkupKeyBoard.TYPE -> {
return convertMarkupKeyBoard((MarkupKeyBoard) keyBoard);
}
case SimpleKeyBoard.TYPE -> {
return convertSimpleKeyBoard((SimpleKeyBoard) keyBoard);
}
}
}
return null;
}
public static ReplyKeyboard convertSimpleKeyBoard(SimpleKeyBoard keyBoard) {
final ReplyKeyboardMarkup keyboardMarkup = new ReplyKeyboardMarkup();
keyboardMarkup.setKeyboard(
keyBoard.getLines().stream()
.map(KeyBoardConvert::convertMarkupLine)
.toList()
);
return keyboardMarkup;
}
public static ReplyKeyboard convertMarkupKeyBoard(MarkupKeyBoard keyBoard) {
if (keyBoard != null) {
if (keyBoard.isNotEmpty()) {

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-sender</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-sender-quarkus</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-sender</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-sender-simple</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-bot</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-simple</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-bot</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-webhook</artifactId>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-webhook</artifactId>
<version>0.0.54-SNAPSHOT</version>
<version>0.0.55-SNAPSHOT</version>
</parent>
<artifactId>telegram-webhook-quarkus</artifactId>