Compare commits

1 Commits

Author SHA1 Message Date
f136aefe31 fix and up version 2022-09-24 14:13:50 +03:00
9 changed files with 39 additions and 24 deletions

View File

@@ -6,7 +6,7 @@
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<artifactId>stbf-parent</artifactId> <artifactId>stbf-parent</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1.1</version>
<name>stbf-parent</name> <name>stbf-parent</name>
<description>Simple Telegram Bot Facade</description> <description>Simple Telegram Bot Facade</description>
@@ -14,7 +14,7 @@
<scm> <scm>
<connection>scm:git:https://git.penkrat.ru/ruslan/stbf.git</connection> <connection>scm:git:https://git.penkrat.ru/ruslan/stbf.git</connection>
<developerConnection>scm:git:https://git.penkrat.ru/ruslan/stbf.git</developerConnection> <developerConnection>scm:git:https://git.penkrat.ru/ruslan/stbf.git</developerConnection>
<tag>HEAD</tag> <tag>stbf-parent-0.0.1</tag>
</scm> </scm>
<licenses> <licenses>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<artifactId>stbf-parent</artifactId> <artifactId>stbf-parent</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</parent> </parent>
<artifactId>stbf-api</artifactId> <artifactId>stbf-api</artifactId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>stbf-parent</artifactId> <artifactId>stbf-parent</artifactId>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</parent> </parent>
<artifactId>stbf-common</artifactId> <artifactId>stbf-common</artifactId>
@@ -14,7 +14,7 @@
<dependency> <dependency>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<artifactId>stbf-api</artifactId> <artifactId>stbf-api</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>stbf-parent</artifactId> <artifactId>stbf-parent</artifactId>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</parent> </parent>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>

View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<artifactId>stbf-parent</artifactId> <artifactId>stbf-parent</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1.1</version>
</parent> </parent>
<artifactId>stbf-pengrad</artifactId> <artifactId>stbf-pengrad</artifactId>
@@ -16,12 +16,12 @@
<dependency> <dependency>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<artifactId>stbf-api</artifactId> <artifactId>stbf-api</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.pengrad</groupId> <groupId>com.github.pengrad</groupId>
<artifactId>java-telegram-bot-api</artifactId> <artifactId>java-telegram-bot-api</artifactId>
<version>[4.9.0,5.2.0]</version> <version>6.2.0</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -1,18 +1,18 @@
package ru.penkrat.stbf.impl.pengrad; package ru.penkrat.stbf.impl.pengrad;
import static lombok.AccessLevel.PROTECTED;
import java.util.Optional;
import com.pengrad.telegrambot.model.CallbackQuery; import com.pengrad.telegrambot.model.CallbackQuery;
import com.pengrad.telegrambot.model.Chat;
import com.pengrad.telegrambot.model.Contact; import com.pengrad.telegrambot.model.Contact;
import com.pengrad.telegrambot.model.Message; import com.pengrad.telegrambot.model.Message;
import com.pengrad.telegrambot.model.Update; import com.pengrad.telegrambot.model.Update;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import ru.penkrat.stbf.api.BotRequest; import ru.penkrat.stbf.api.BotRequest;
import java.util.Optional;
import static lombok.AccessLevel.PROTECTED;
@RequiredArgsConstructor @RequiredArgsConstructor
public class BotRequestImpl implements BotRequest { public class BotRequestImpl implements BotRequest {
@@ -52,10 +52,25 @@ public class BotRequestImpl implements BotRequest {
@Override @Override
public Long getChatId() { public Long getChatId() {
return Optional.of(update) return Optional.ofNullable(getMessage())
.map(Update::callbackQuery) .map(Message::chat)
.map(CallbackQuery::message) .map(Chat::id)
.orElseGet(() -> update.message()).chat().id(); .orElse(null);
}
private Message getMessage() {
if (update != null) {
if (update.callbackQuery() != null) {
return update.callbackQuery().message();
}
if (update.message() != null) {
return update.message();
}
if (update.editedMessage() != null) {
return update.editedMessage();
}
}
return null;
} }
} }

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>stbf-parent</artifactId> <artifactId>stbf-parent</artifactId>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</parent> </parent>
<artifactId>stbf-rubenlagus</artifactId> <artifactId>stbf-rubenlagus</artifactId>
@@ -15,7 +15,7 @@
<dependency> <dependency>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<artifactId>stbf-api</artifactId> <artifactId>stbf-api</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.telegram</groupId> <groupId>org.telegram</groupId>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>stbf-parent</artifactId> <artifactId>stbf-parent</artifactId>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</parent> </parent>
<artifactId>stbf-templates</artifactId> <artifactId>stbf-templates</artifactId>
<properties> <properties>

View File

@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>stbf-parent</artifactId> <artifactId>stbf-parent</artifactId>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</parent> </parent>
<artifactId>stbf-test</artifactId> <artifactId>stbf-test</artifactId>
@@ -14,12 +14,12 @@
<dependency> <dependency>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<artifactId>stbf-api</artifactId> <artifactId>stbf-api</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ru.penkrat.stbf</groupId> <groupId>ru.penkrat.stbf</groupId>
<artifactId>stbf-common</artifactId> <artifactId>stbf-common</artifactId>
<version>0.0.2-SNAPSHOT</version> <version>0.0.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>