Обновлены версии библиотек. Обновление с API телеги: теперь при нажатии кнопки телеграм не всегда присылает сообщение с этой кнопкой. Если сообщение старое, то самое сообщение может быть не отправлено.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Struchkov Mark 2024-06-24 16:40:48 +03:00
parent 04e5d3435b
commit 2d79362e67
No known key found for this signature in database
GPG Key ID: A3F0AC3F0FA52F3C
4 changed files with 35 additions and 29 deletions

20
pom.xml
View File

@ -38,28 +38,28 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<godfather.core.ver>1.2.0</godfather.core.ver> <godfather.core.ver>1.3.0</godfather.core.ver>
<!-- https://mvnrepository.com/artifact/org.telegram/telegrambots --> <!-- https://mvnrepository.com/artifact/org.telegram/telegrambots -->
<telegrambots.ver>6.8.0</telegrambots.ver> <telegrambots.ver>6.9.7.1</telegrambots.ver>
<!-- https://mvnrepository.com/artifact/io.smallrye.reactive/smallrye-mutiny-vertx-core --> <!-- https://mvnrepository.com/artifact/io.smallrye.reactive/smallrye-mutiny-vertx-core -->
<smallrye.mutiny.vertx.core.version>3.3.0</smallrye.mutiny.vertx.core.version> <smallrye.mutiny.vertx.core.version>3.13.1</smallrye.mutiny.vertx.core.version>
<haiti.version>2.7.2</haiti.version> <haiti.version>3.0.3</haiti.version>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin.maven.compiler.ver>3.11.0</plugin.maven.compiler.ver> <plugin.maven.compiler.ver>3.13.0</plugin.maven.compiler.ver>
<!-- https://mvnrepository.com/artifact/org.sonatype.plugins/nexus-staging-maven-plugin --> <!-- https://mvnrepository.com/artifact/org.sonatype.plugins/nexus-staging-maven-plugin -->
<plugin.nexus.staging.ver>1.6.13</plugin.nexus.staging.ver> <plugin.nexus.staging.ver>1.7.0</plugin.nexus.staging.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-source-plugin --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-source-plugin -->
<plugin.maven.source.ver>3.3.0</plugin.maven.source.ver> <plugin.maven.source.ver>3.3.1</plugin.maven.source.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin -->
<plugin.maven.javadoc.ver>3.6.0</plugin.maven.javadoc.ver> <plugin.maven.javadoc.ver>3.7.0</plugin.maven.javadoc.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-gpg-plugin --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-gpg-plugin -->
<plugin.maven.gpg.ver>3.1.0</plugin.maven.gpg.ver> <plugin.maven.gpg.ver>3.2.4</plugin.maven.gpg.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-release-plugin --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-release-plugin -->
<plugin.maven.release.ver>3.0.1</plugin.maven.release.ver> <plugin.maven.release.ver>3.1.0</plugin.maven.release.ver>
</properties> </properties>
<dependencyManagement> <dependencyManagement>

View File

@ -16,6 +16,7 @@ import dev.struchkov.godfather.telegram.simple.context.service.TelegramConnect;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.telegram.telegrambots.meta.api.objects.CallbackQuery; import org.telegram.telegrambots.meta.api.objects.CallbackQuery;
import org.telegram.telegrambots.meta.api.objects.ChatMemberUpdated; import org.telegram.telegrambots.meta.api.objects.ChatMemberUpdated;
import org.telegram.telegrambots.meta.api.objects.MaybeInaccessibleMessage;
import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update; import org.telegram.telegrambots.meta.api.objects.Update;
import org.telegram.telegrambots.meta.api.objects.User; import org.telegram.telegrambots.meta.api.objects.User;
@ -87,29 +88,23 @@ public class EventDistributorService implements EventDistributor {
} }
private void processionCallback(CallbackQuery callbackQuery) { private void processionCallback(CallbackQuery callbackQuery) {
final Message message = callbackQuery.getMessage(); final MaybeInaccessibleMessage maybeInaccessibleMessage = callbackQuery.getMessage();
if (checkNotBlank(callbackQuery.getInlineMessageId())) { if (checkNotBlank(callbackQuery.getInlineMessageId())) {
return; return;
} }
if (checkNotNull(message)) { if (checkNotNull(maybeInaccessibleMessage) && maybeInaccessibleMessage.isUserMessage()) {
final Long fromId = message.getChat().getId();
if (fromId < 0) {
} else {
final Mail mail = CallbackQueryConvert.apply(callbackQuery); final Mail mail = CallbackQueryConvert.apply(callbackQuery);
eventDispatching.dispatch(new EventContainer<>(Mail.class, mail)); eventDispatching.dispatch(new EventContainer<>(Mail.class, mail));
} }
} }
}
private void processionMessage(Message message) { private void processionMessage(Message message) {
final Long fromId = message.getChat().getId(); if (message.isUserMessage()) {
if (fromId < 0) {
final ChatMail chatMail = MessageChatMailConvert.apply(message);
eventDispatching.dispatch(new EventContainer<>(ChatMail.class, chatMail));
} else {
final Mail mail = MessageMailConvert.apply(message); final Mail mail = MessageMailConvert.apply(message);
eventDispatching.dispatch(new EventContainer<>(Mail.class, mail)); eventDispatching.dispatch(new EventContainer<>(Mail.class, mail));
} else {
final ChatMail chatMail = MessageChatMailConvert.apply(message);
eventDispatching.dispatch(new EventContainer<>(ChatMail.class, chatMail));
} }
} }

View File

@ -3,6 +3,7 @@ package dev.struchkov.godfather.telegram.main.context.convert;
import dev.struchkov.godfather.main.domain.content.Mail; import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
import org.telegram.telegrambots.meta.api.objects.CallbackQuery; import org.telegram.telegrambots.meta.api.objects.CallbackQuery;
import org.telegram.telegrambots.meta.api.objects.MaybeInaccessibleMessage;
import org.telegram.telegrambots.meta.api.objects.Message; import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.User; import org.telegram.telegrambots.meta.api.objects.User;
@ -19,10 +20,12 @@ public class CallbackQueryConvert {
final String callbackData = callbackQuery.getData(); final String callbackData = callbackQuery.getData();
final Mail mail = new Mail(); final Mail mail = new Mail();
mail.setId(callbackQuery.getMessage().getMessageId().toString()); final MaybeInaccessibleMessage maybeInaccessibleMessage = callbackQuery.getMessage();
mail.setId(maybeInaccessibleMessage.getMessageId().toString());
mail.setCreateDate(LocalDateTime.now()); mail.setCreateDate(LocalDateTime.now());
mail.setText(callbackData); mail.setText(callbackData);
mail.addAttachment(convertToButtonClick(callbackData, callbackQuery.getMessage())); mail.addAttachment(convertToButtonClick(callbackData, maybeInaccessibleMessage));
final Long chatId = callbackQuery.getFrom().getId(); final Long chatId = callbackQuery.getFrom().getId();
mail.setFromPersonId(chatId.toString()); mail.setFromPersonId(chatId.toString());
@ -33,10 +36,13 @@ public class CallbackQueryConvert {
return mail; return mail;
} }
private static ButtonClickAttachment convertToButtonClick(String callbackData, Message message) { private static ButtonClickAttachment convertToButtonClick(String callbackData, MaybeInaccessibleMessage maybeInaccessibleMessage) {
final ButtonClickAttachment buttonClickAttachment = new ButtonClickAttachment(); final ButtonClickAttachment buttonClickAttachment = new ButtonClickAttachment();
buttonClickAttachment.setRawCallBackData(callbackData); buttonClickAttachment.setRawCallBackData(callbackData);
buttonClickAttachment.setMessage(MessageMailConvert.apply(message)); if (maybeInaccessibleMessage instanceof Message message) {
buttonClickAttachment.setMaybeInaccessibleMessage(MessageMailConvert.apply(message));
}
if (callbackData.charAt(0) == '[' && callbackData.charAt(callbackData.length() - 1) == ']') { if (callbackData.charAt(0) == '[' && callbackData.charAt(callbackData.length() - 1) == ']') {
final String[] args = callbackData.substring(1, callbackData.length() - 1).split(";"); final String[] args = callbackData.substring(1, callbackData.length() - 1).split(";");
for (String arg : args) { for (String arg : args) {

View File

@ -19,7 +19,7 @@ import static dev.struchkov.haiti.utils.Inspector.isNotNull;
public class ButtonClickAttachment extends Attachment { public class ButtonClickAttachment extends Attachment {
private String rawCallBackData; private String rawCallBackData;
private Mail message; private Mail maybeInaccessibleMessage;
private Map<String, ButtonArg> args = new HashMap<>(); private Map<String, ButtonArg> args = new HashMap<>();
@ -27,6 +27,11 @@ public class ButtonClickAttachment extends Attachment {
super(TelegramAttachmentType.BUTTON_CLICK.name()); super(TelegramAttachmentType.BUTTON_CLICK.name());
} }
@JsonIgnore
public Optional<Mail> getMessage() {
return Optional.ofNullable(maybeInaccessibleMessage);
}
@JsonIgnore @JsonIgnore
public void addClickArg(String type, String value) { public void addClickArg(String type, String value) {
isNotNull(type, value); isNotNull(type, value);