API improvements
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-09-10 19:19:50 +03:00
parent 24b15ca4fe
commit c5806b6b45
4 changed files with 13 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
package ru.penkrat.stbf.api; package ru.penkrat.stbf.api;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import lombok.AccessLevel; import lombok.AccessLevel;
@@ -36,4 +37,9 @@ public class BotCommandChain implements CommandChain {
return this; return this;
} }
public BotCommandChain addAll(Collection<Command> cmds) {
commands.addAll(cmds);
return this;
}
} }

View File

@@ -12,6 +12,10 @@ public abstract class AbstractActionCommand implements Command {
private RequestMatcher matcher; private RequestMatcher matcher;
public AbstractActionCommand(RequestMatcher matcher) {
this.matcher = matcher;
}
public AbstractActionCommand(Action action) { public AbstractActionCommand(Action action) {
matcher = RequestMatchers.action(action); matcher = RequestMatchers.action(action);
} }

View File

@@ -1,5 +1,6 @@
package ru.penkrat.stbf.common.command; package ru.penkrat.stbf.common.command;
import lombok.RequiredArgsConstructor;
import ru.penkrat.stbf.api.Action; import ru.penkrat.stbf.api.Action;
import ru.penkrat.stbf.api.BotRequest; import ru.penkrat.stbf.api.BotRequest;
import ru.penkrat.stbf.api.BotResponse; import ru.penkrat.stbf.api.BotResponse;
@@ -10,6 +11,7 @@ import ru.penkrat.stbf.api.Screen;
import ru.penkrat.stbf.common.screen.TextScreen; import ru.penkrat.stbf.common.screen.TextScreen;
import ru.penkrat.stbf.tools.RequestMatchers; import ru.penkrat.stbf.tools.RequestMatchers;
@RequiredArgsConstructor
public class SimpleCommand implements Command { public class SimpleCommand implements Command {
private final RequestMatcher matcher; private final RequestMatcher matcher;

View File

@@ -24,9 +24,7 @@ public class PengradKeyboardBuilder implements KeyboardBuilder {
return new KeyboardImpl(keyboard, null); return new KeyboardImpl(keyboard, null);
} }
if (inlineKeyboard != null) { if (inlineKeyboard != null) {
InlineKeyboardButton[][] smallerArray = new InlineKeyboardButton[inlineKeyboard.length - 1][]; return new KeyboardImpl(null, inlineKeyboard);
System.arraycopy(inlineKeyboard, 0, smallerArray, 0, inlineKeyboard.length - 1);
return new KeyboardImpl(null, smallerArray);
} }
return new NoKeyboard(); return new NoKeyboard();
} }