Compare commits
2 Commits
0.0.2
...
0e1b44a920
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e1b44a920 | |||
| 6fc2748779 |
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<artifactId>stbf-parent</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
<name>stbf-parent</name>
|
||||
|
||||
<description>Simple Telegram Bot Facade</description>
|
||||
@@ -14,7 +14,7 @@
|
||||
<scm>
|
||||
<connection>scm:git:https://git.penkrat.ru/ruslan/stbf.git</connection>
|
||||
<developerConnection>scm:git:https://git.penkrat.ru/ruslan/stbf.git</developerConnection>
|
||||
<tag>0.0.2</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<licenses>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<artifactId>stbf-parent</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>stbf-api</artifactId>
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>stbf-parent</artifactId>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>stbf-common</artifactId>
|
||||
@@ -14,7 +14,7 @@
|
||||
<dependency>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<artifactId>stbf-api</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>stbf-parent</artifactId>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<artifactId>stbf-parent</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>stbf-pengrad</artifactId>
|
||||
@@ -16,12 +16,12 @@
|
||||
<dependency>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<artifactId>stbf-api</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pengrad</groupId>
|
||||
<artifactId>java-telegram-bot-api</artifactId>
|
||||
<version>7.1.1</version>
|
||||
<version>9.4.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ru.penkrat.stbf.impl.pengrad;
|
||||
|
||||
import com.pengrad.telegrambot.TelegramBot;
|
||||
import com.pengrad.telegrambot.model.LinkPreviewOptions;
|
||||
import com.pengrad.telegrambot.model.Message;
|
||||
import com.pengrad.telegrambot.model.Update;
|
||||
import com.pengrad.telegrambot.model.request.InlineKeyboardButton;
|
||||
import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup;
|
||||
@@ -58,7 +60,10 @@ public class BotResponseImpl implements BotResponse {
|
||||
|
||||
@Override
|
||||
public void sendFile(String filename, byte[] data) {
|
||||
telegramBot.execute(new SendDocument(chatId(), data).fileName(filename));
|
||||
Message message = telegramBot.execute(new SendDocument((long) chatId(), data)
|
||||
.fileName(filename)
|
||||
).message();
|
||||
log.debug("Send file message = {}", message.messageId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,14 +71,14 @@ public class BotResponseImpl implements BotResponse {
|
||||
public void editMessage(String text) {
|
||||
telegramBot.execute(new EditMessageText(chatId(), messageId(), text)
|
||||
.parseMode(ParseMode.HTML)
|
||||
.disableWebPagePreview(true));
|
||||
.linkPreviewOptions(new LinkPreviewOptions().isDisabled(true)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(Screen screen) {
|
||||
EditMessageText editMessage = new EditMessageText(chatId(), messageId(), screen.getText())
|
||||
.parseMode(screen.getScreenProperties().isParseModeHtml() ? ParseMode.HTML : ParseMode.MarkdownV2)
|
||||
.disableWebPagePreview(screen.getScreenProperties().isDisableWebPagePreview());
|
||||
.linkPreviewOptions(new LinkPreviewOptions().isDisabled(screen.getScreenProperties().isDisableWebPagePreview()));
|
||||
|
||||
if (screen.getKeyboard() instanceof KeyboardImpl) {
|
||||
KeyboardImpl kk = (KeyboardImpl) screen.getKeyboard();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.penkrat.stbf.impl.pengrad;
|
||||
|
||||
import com.pengrad.telegrambot.model.LinkPreviewOptions;
|
||||
import com.pengrad.telegrambot.model.Message;
|
||||
import com.pengrad.telegrambot.model.request.ParseMode;
|
||||
import com.pengrad.telegrambot.request.AbstractSendRequest;
|
||||
@@ -23,7 +24,8 @@ import java.util.function.Consumer;
|
||||
@UtilityClass
|
||||
class SendMethodUtils {
|
||||
|
||||
public AbstractSendRequest<? extends AbstractSendRequest> createFromScreen(@NonNull Object chatId, @NonNull Screen screen) {
|
||||
public AbstractSendRequest<? extends AbstractSendRequest> createFromScreen(@NonNull Object chatIdObj, @NonNull Screen screen) {
|
||||
long chatId = chatIdObj instanceof Long ? (Long) chatIdObj : 0;
|
||||
if (isMedia(screen)) {
|
||||
final Media media = screen.getMedia();
|
||||
switch (media.getMediaType()) {
|
||||
@@ -77,7 +79,8 @@ class SendMethodUtils {
|
||||
|
||||
return new SendMessage(chatId, screen.getText().trim())
|
||||
.parseMode(screen.getScreenProperties().isParseModeHtml() ? ParseMode.HTML : ParseMode.MarkdownV2)
|
||||
.disableWebPagePreview(screen.getScreenProperties().isDisableWebPagePreview())
|
||||
.linkPreviewOptions(new LinkPreviewOptions().isDisabled(screen.getScreenProperties().isDisableWebPagePreview()))
|
||||
// .disableWebPagePreview(screen.getScreenProperties().isDisableWebPagePreview())
|
||||
.disableNotification(screen.getScreenProperties().isDisableNotification());
|
||||
}
|
||||
|
||||
@@ -102,7 +105,8 @@ class SendMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SendVoice createSendVoice(@NotNull Object chatId, Media media) {
|
||||
private SendVoice createSendVoice(@NotNull Object chatIdObj, Media media) {
|
||||
long chatId = chatIdObj instanceof Long ? (Long) chatIdObj : 0;
|
||||
if (media.getData() != null) {
|
||||
return new SendVoice(chatId, media.getData().get());
|
||||
}
|
||||
@@ -113,7 +117,8 @@ class SendMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SendVideo createSendVideo(@NotNull Object chatId, Media media) {
|
||||
private SendVideo createSendVideo(@NotNull Object chatIdObj, Media media) {
|
||||
long chatId = chatIdObj instanceof Long ? (Long) chatIdObj : 0;
|
||||
if (media.getData() != null) {
|
||||
return new SendVideo(chatId, media.getData().get());
|
||||
}
|
||||
@@ -124,7 +129,8 @@ class SendMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SendAudio createSendAudio(@NotNull Object chatId, Media media) {
|
||||
private SendAudio createSendAudio(@NotNull Object chatIdObj, Media media) {
|
||||
long chatId = chatIdObj instanceof Long ? (Long) chatIdObj : 0;
|
||||
if (media.getData() != null) {
|
||||
return new SendAudio(chatId, media.getData().get());
|
||||
}
|
||||
@@ -135,7 +141,8 @@ class SendMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SendAnimation createSendAnimation(@NotNull Object chatId, Media media) {
|
||||
private SendAnimation createSendAnimation(@NotNull Object chatIdObj, Media media) {
|
||||
long chatId = chatIdObj instanceof Long ? (Long) chatIdObj : 0;
|
||||
if (media.getData() != null) {
|
||||
return new SendAnimation(chatId, media.getData().get());
|
||||
}
|
||||
@@ -146,7 +153,8 @@ class SendMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private SendPhoto createSendPhoto(@NotNull Object chatId, Media media) {
|
||||
private SendPhoto createSendPhoto(@NotNull Object chatIdObj, Media media) {
|
||||
long chatId = chatIdObj instanceof Long ? (Long) chatIdObj : 0;
|
||||
if (media.getData() != null) {
|
||||
return new SendPhoto(chatId, media.getData().get());
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>stbf-parent</artifactId>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>stbf-rubenlagus</artifactId>
|
||||
@@ -15,7 +15,7 @@
|
||||
<dependency>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<artifactId>stbf-api</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.telegram</groupId>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>stbf-parent</artifactId>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>stbf-templates</artifactId>
|
||||
<properties>
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>stbf-parent</artifactId>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>stbf-test</artifactId>
|
||||
@@ -14,12 +14,12 @@
|
||||
<dependency>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<artifactId>stbf-api</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.penkrat.stbf</groupId>
|
||||
<artifactId>stbf-common</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
Reference in New Issue
Block a user