Compare commits

...

24 Commits

Author SHA1 Message Date
Struchkov Mark ef189e9baa
update dependencies and cicd
continuous-integration/drone/push Build is passing Details
2024-01-19 19:49:28 +03:00
Struchkov Mark 4a93ab5274
[maven-release-plugin] prepare for next development iteration
continuous-integration/drone/push Build is passing Details
2023-04-30 10:33:46 +03:00
Struchkov Mark 88e4a82372
[maven-release-plugin] prepare release v.0.0.57 2023-04-30 10:33:45 +03:00
Struchkov Mark f616dd30ba
prerelease 2023-04-30 10:33:34 +03:00
Struchkov Mark ef605cf098
Удалил использование PersonSetting 2023-04-30 10:32:48 +03:00
Struchkov Mark 084f39be0b
Удалил использование PersonSetting 2023-04-24 10:05:39 +03:00
Struchkov Mark 5e433b76ef
Подготовка релиза 2023-04-24 10:04:25 +03:00
Struchkov Mark 015c3246a7
Актуализация версии
continuous-integration/drone/push Build is passing Details
2023-04-22 17:24:33 +03:00
Struchkov Mark 502767a514
Актуализация версии
continuous-integration/drone/push Build is passing Details
2023-04-10 10:12:44 +03:00
Struchkov Mark 9e5a8756d4
[maven-release-plugin] prepare for next development iteration 2023-04-09 22:07:00 +03:00
Struchkov Mark 1da4bda2f4
[maven-release-plugin] prepare release v.0.0.55 2023-04-09 22:06:59 +03:00
Struchkov Mark 16b94d8508
pre release 2023-04-09 22:06:45 +03:00
Struchkov Mark 030b62e179
Актуализировал версии
continuous-integration/drone/push Build is passing Details
2023-04-09 11:24:37 +03:00
Struchkov Mark 6e11f53a8c
[maven-release-plugin] prepare for next development iteration
continuous-integration/drone/push Build is passing Details
2023-03-29 01:22:18 +03:00
Struchkov Mark 7e3f8343f3
[maven-release-plugin] prepare release v.0.0.54 2023-03-29 01:22:17 +03:00
Struchkov Mark aa64f06dd8
Поправил стартер 2023-03-29 01:21:47 +03:00
Struchkov Mark ffd90c9d68
Поправил стартер
continuous-integration/drone/push Build is failing Details
continuous-integration/drone Build is passing Details
2023-03-26 17:43:08 +03:00
Struchkov Mark bea9978ef6
Поправил стартер
continuous-integration/drone/push Build is passing Details
2023-03-22 04:18:01 +03:00
Struchkov Mark 91ccbb5a90
[maven-release-plugin] prepare for next development iteration
continuous-integration/drone/push Build is passing Details
2023-03-16 00:49:47 +03:00
Struchkov Mark a39f4c33c3
[maven-release-plugin] prepare release v.0.0.53 2023-03-16 00:49:47 +03:00
Struchkov Mark 76cd50f99b
Подготовка к релизу 2023-03-16 00:49:31 +03:00
Struchkov Mark 6d676a12c6
Добавление конфигурации групповых чатов
continuous-integration/drone/push Build is passing Details
2023-03-15 20:51:18 +03:00
Struchkov Mark 1208c5b2fe
Подготовка к релизу 0.0.53
continuous-integration/drone/push Build is passing Details
2023-03-15 00:04:18 +03:00
Struchkov Mark 128216b717
[maven-release-plugin] prepare for next development iteration
continuous-integration/drone/push Build is passing Details
2023-03-05 19:00:09 +03:00
7 changed files with 174 additions and 109 deletions

View File

@ -13,9 +13,8 @@ volumes:
path: /drone/volume/m2
steps:
- name: publish
image: maven:3.8.5-openjdk-17
image: hub.docker.struchkov.dev/maven:3.9.5-eclipse-temurin-17-alpine
privileged: true
volumes:
- name: m2
@ -42,9 +41,8 @@ volumes:
path: /drone/volume/m2
steps:
- name: publish maven central
image: maven:3.8.5-openjdk-17
image: hub.docker.struchkov.dev/maven:3.9.5-eclipse-temurin-17-alpine
privileged: true
volumes:
- name: m2
@ -57,6 +55,7 @@ steps:
GPG_PASSPHRASE:
from_secret: GPG_PASSPHRASE
commands:
- apk add --no-cache gnupg
- echo "$GPG_PRIVATE_KEY" >> gpg.key
- echo "$MAVEN_SETTINGS" >> maven-settings.xml
- gpg --pinentry-mode loopback --passphrase $GPG_PASSPHRASE --import gpg.key
@ -77,9 +76,8 @@ volumes:
path: /drone/volume/m2
steps:
- name: publish struchkov nexus
image: maven:3.8.5-openjdk-17
image: hub.docker.struchkov.dev/maven:3.9.5-eclipse-temurin-17-alpine
privileged: true
volumes:
- name: m2
@ -92,6 +90,7 @@ steps:
GPG_PASSPHRASE:
from_secret: GPG_PASSPHRASE
commands:
- apk add --no-cache gnupg
- echo "$GPG_PRIVATE_KEY" >> gpg.key
- echo "$MAVEN_SETTINGS" >> maven-settings.xml
- gpg --pinentry-mode loopback --passphrase $GPG_PASSPHRASE --import gpg.key
@ -99,6 +98,6 @@ steps:
---
kind: signature
hmac: 6aa5185200940abe95b0bb1c4cb7fc958faee27e88fb3ae4e4694b9a2da871b0
hmac: 66796c2b300a4fe5e185561985fb867cb7f0ce0ab98babd264a4bf2ff6246228
...

20
pom.xml
View File

@ -10,7 +10,7 @@
<groupId>dev.struchkov.godfather.telegram</groupId>
<artifactId>telegram-bot-spring-boot-starter</artifactId>
<version>0.0.51</version>
<version>1.0.0-SNAPSHOT</version>
<properties>
<java.version>17</java.version>
@ -19,21 +19,23 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<telegram.bot.version>0.0.51</telegram.bot.version>
<godfather.version>0.0.52</godfather.version>
<!-- https://mvnrepository.com/artifact/dev.struchkov.godfather/bot-data-simple -->
<godfather.version>1.2.0</godfather.version>
<!-- https://mvnrepository.com/artifact/dev.struchkov.godfather.telegram/telegram-consumer-simple -->
<telegram.bot.version>1.4.0</telegram.bot.version>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin.maven.compiler.ver>3.10.1</plugin.maven.compiler.ver>
<plugin.maven.compiler.ver>3.12.1</plugin.maven.compiler.ver>
<!-- https://mvnrepository.com/artifact/org.sonatype.plugins/nexus-staging-maven-plugin -->
<plugin.nexus.staging.ver>1.6.13</plugin.nexus.staging.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-source-plugin -->
<plugin.maven.source.ver>3.2.1</plugin.maven.source.ver>
<plugin.maven.source.ver>3.3.0</plugin.maven.source.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin -->
<plugin.maven.javadoc.ver>3.5.0</plugin.maven.javadoc.ver>
<plugin.maven.javadoc.ver>3.6.3</plugin.maven.javadoc.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-gpg-plugin -->
<plugin.maven.gpg.ver>3.0.1</plugin.maven.gpg.ver>
<plugin.maven.gpg.ver>3.1.0</plugin.maven.gpg.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-release-plugin -->
<plugin.maven.release.ver>3.0.0-M7</plugin.maven.release.ver>
<plugin.maven.release.ver>3.0.1</plugin.maven.release.ver>
</properties>
<dependencies>
@ -297,7 +299,7 @@
<url>https://git.struchkov.dev/Godfather-Bots/telegram-bot-spring-boot-starter</url>
<developerConnection>scm:git:https://git.struchkov.dev/Godfather-Bots/telegram-bot-spring-boot-starter.git
</developerConnection>
<tag>v.0.0.51</tag>
<tag>v.0.0.56</tag>
</scm>
<developers>

View File

@ -1,5 +1,5 @@
package dev.struchkov.godfather.telegram.starter;
public interface UnitConfiguration {
public interface ChatUnitConfiguration {
}

View File

@ -0,0 +1,5 @@
package dev.struchkov.godfather.telegram.starter;
public interface PersonUnitConfiguration {
}

View File

@ -1,35 +1,40 @@
package dev.struchkov.godfather.telegram.starter.config;
import dev.struchkov.godfather.main.domain.content.ChatMail;
import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.context.repository.PersonSettingRepository;
import dev.struchkov.godfather.simple.context.repository.StorylineRepository;
import dev.struchkov.godfather.simple.context.repository.UnitPointerRepository;
import dev.struchkov.godfather.simple.context.service.ErrorHandler;
import dev.struchkov.godfather.simple.context.service.EventDispatching;
import dev.struchkov.godfather.simple.context.service.EventHandler;
import dev.struchkov.godfather.simple.context.service.PersonSettingService;
import dev.struchkov.godfather.simple.context.service.UnitPointerService;
import dev.struchkov.godfather.simple.core.action.AnswerTextAction;
import dev.struchkov.godfather.simple.core.provider.StoryLineHandler;
import dev.struchkov.godfather.simple.core.service.PersonSettingServiceImpl;
import dev.struchkov.godfather.simple.core.EventDispatchingImpl;
import dev.struchkov.godfather.simple.core.action.AnswerCheckAction;
import dev.struchkov.godfather.simple.core.action.AnswerSaveAction;
import dev.struchkov.godfather.simple.core.action.AnswerTextChatMailAction;
import dev.struchkov.godfather.simple.core.action.AnswerTextMailAction;
import dev.struchkov.godfather.simple.core.provider.ChatStoryLineHandler;
import dev.struchkov.godfather.simple.core.provider.PersonStoryLineHandler;
import dev.struchkov.godfather.simple.core.service.StorylineMailService;
import dev.struchkov.godfather.simple.core.service.StorylineService;
import dev.struchkov.godfather.simple.core.service.UnitPointerServiceImpl;
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
import dev.struchkov.godfather.telegram.simple.consumer.EventDistributorService;
import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository;
import dev.struchkov.godfather.telegram.simple.context.service.EventDistributor;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramConnect;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramService;
import dev.struchkov.godfather.telegram.simple.core.ChatMailAutoresponderTelegram;
import dev.struchkov.godfather.telegram.simple.core.MailAutoresponderTelegram;
import dev.struchkov.godfather.telegram.simple.core.TelegramConnectBot;
import dev.struchkov.godfather.telegram.simple.core.service.TelegramServiceImpl;
import dev.struchkov.godfather.telegram.simple.sender.TelegramSender;
import dev.struchkov.godfather.telegram.starter.UnitConfiguration;
import dev.struchkov.godfather.telegram.starter.ChatUnitConfiguration;
import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import dev.struchkov.godfather.telegram.starter.property.TelegramBotAutoresponderProperty;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -45,7 +50,7 @@ import static dev.struchkov.haiti.utils.Checker.checkNotNull;
@AutoConfigureAfter(TelegramBotDataConfiguration.class)
public class TelegramBotAutoconfiguration {
@ConditionalOnBean(TelegramConnectBot.class)
@ConditionalOnBean(TelegramConnect.class)
@Bean(AUTORESPONDER_EXECUTORS_SERVICE)
public ExecutorService executorService(
TelegramBotAutoresponderProperty autoresponderProperty
@ -65,44 +70,6 @@ public class TelegramBotAutoconfiguration {
return new UnitPointerServiceImpl(unitPointerRepository);
}
@Bean
@ConditionalOnBean(PersonSettingRepository.class)
public PersonSettingService personSettingService(PersonSettingRepository personSettingRepository) {
return new PersonSettingServiceImpl(personSettingRepository);
}
@Bean
@ConditionalOnBean(TelegramConnectBot.class)
public MailAutoresponderTelegram messageAutoresponderTelegram(
@Qualifier(AUTORESPONDER_EXECUTORS_SERVICE) ObjectProvider<ExecutorService> executorServiceProvider,
TelegramSending sending,
PersonSettingService personSettingService,
ObjectProvider<ErrorHandler> errorHandlerProvider,
ObjectProvider<AnswerTextAction> answerTextActionProvider,
StorylineService<Mail> storylineService
) {
final MailAutoresponderTelegram autoresponder = new MailAutoresponderTelegram(
sending, personSettingService, storylineService
);
final ExecutorService executorService = executorServiceProvider.getIfAvailable();
if (checkNotNull(executorService)) {
autoresponder.setExecutorService(executorService);
}
final ErrorHandler errorHandler = errorHandlerProvider.getIfAvailable();
if (checkNotNull(errorHandler)) {
autoresponder.setErrorHandler(errorHandler);
}
final AnswerTextAction answerTextAction = answerTextActionProvider.getIfAvailable();
if (checkNotNull(answerTextAction)) {
autoresponder.initTextAnswerActionUnit(answerTextAction);
}
return autoresponder;
}
@Bean
@ConditionalOnBean(TelegramConnect.class)
public TelegramSending sending(
@ -119,32 +86,123 @@ public class TelegramBotAutoconfiguration {
return telegramSender;
}
@Bean
@ConditionalOnBean(MailAutoresponderTelegram.class)
public StoryLineHandler storyLineHandler(MailAutoresponderTelegram mailAutoresponderTelegram) {
return new StoryLineHandler(mailAutoresponderTelegram);
}
@Bean
@ConditionalOnBean(TelegramConnectBot.class)
public EventDistributor eventDistributor(
TelegramConnectBot telegramConnect, List<EventHandler> eventProviders
) {
return new EventDistributorService(telegramConnect, eventProviders);
}
@Bean
@ConditionalOnBean(value = {UnitPointerService.class, StorylineRepository.class})
public StorylineService<Mail> storylineService(
@Bean("mailStorylineService")
@ConditionalOnBean(value = {UnitPointerService.class, PersonUnitConfiguration.class})
public StorylineService<Mail> mailStorylineService(
UnitPointerService unitPointerService,
StorylineRepository storylineRepository,
List<UnitConfiguration> unitConfigurations
List<PersonUnitConfiguration> personUnitConfigurations
) {
return new StorylineMailService(
return new StorylineMailService<>(
unitPointerService,
storylineRepository,
new ArrayList<>(unitConfigurations)
new ArrayList<>(personUnitConfigurations)
);
}
@Bean("chatMailStorylineService")
@ConditionalOnBean(value = {UnitPointerService.class, ChatUnitConfiguration.class})
public StorylineService<ChatMail> chatMailStorylineService(
UnitPointerService unitPointerService,
List<ChatUnitConfiguration> chatUnitConfigurations
) {
return new StorylineMailService<>(
unitPointerService,
new ArrayList<>(chatUnitConfigurations)
);
}
@Bean
@ConditionalOnBean(name = "chatMailStorylineService")
public ChatMailAutoresponderTelegram chatMailAutoresponderTelegram(
@Qualifier(AUTORESPONDER_EXECUTORS_SERVICE) ObjectProvider<ExecutorService> executorServiceProvider,
ObjectProvider<ErrorHandler> errorHandlerProvider,
ObjectProvider<AnswerTextChatMailAction> answerTextActionProvider,
TelegramSending telegramSending,
StorylineService<ChatMail> storylineService
) {
final ChatMailAutoresponderTelegram autoresponder = new ChatMailAutoresponderTelegram(storylineService);
autoresponder.registrationActionUnit(new AnswerCheckAction(telegramSending));
autoresponder.registrationActionUnit(new AnswerSaveAction<>());
final AnswerTextChatMailAction answerTextAction = answerTextActionProvider.getIfAvailable();
if (checkNotNull(answerTextAction)) {
autoresponder.registrationActionUnit(answerTextAction);
} else {
autoresponder.registrationActionUnit(new AnswerTextChatMailAction(telegramSending));
}
final ExecutorService executorService = executorServiceProvider.getIfAvailable();
if (checkNotNull(executorService)) {
autoresponder.setExecutorService(executorService);
}
final ErrorHandler errorHandler = errorHandlerProvider.getIfAvailable();
if (checkNotNull(errorHandler)) {
autoresponder.setErrorHandler(errorHandler);
}
return autoresponder;
}
@Bean
@ConditionalOnBean(name = "mailStorylineService")
public MailAutoresponderTelegram messageAutoresponderTelegram(
@Qualifier(AUTORESPONDER_EXECUTORS_SERVICE) ObjectProvider<ExecutorService> executorServiceProvider,
TelegramSending sending,
ObjectProvider<ErrorHandler> errorHandlerProvider,
ObjectProvider<AnswerTextMailAction> answerTextActionProvider,
StorylineService<Mail> storylineService
) {
final MailAutoresponderTelegram autoresponder = new MailAutoresponderTelegram(storylineService);
autoresponder.registrationActionUnit(new AnswerCheckAction(sending));
autoresponder.registrationActionUnit(new AnswerSaveAction<>());
final AnswerTextMailAction answerTextAction = answerTextActionProvider.getIfAvailable();
if (checkNotNull(answerTextAction)) {
autoresponder.registrationActionUnit(answerTextAction);
} else {
autoresponder.registrationActionUnit(new AnswerTextMailAction(sending));
}
final ExecutorService executorService = executorServiceProvider.getIfAvailable();
if (checkNotNull(executorService)) {
autoresponder.setExecutorService(executorService);
}
final ErrorHandler errorHandler = errorHandlerProvider.getIfAvailable();
if (checkNotNull(errorHandler)) {
autoresponder.setErrorHandler(errorHandler);
}
return autoresponder;
}
@Bean
@ConditionalOnBean(MailAutoresponderTelegram.class)
public EventHandler<Mail> personStoryLineHandler(MailAutoresponderTelegram mailAutoresponderTelegram) {
return new PersonStoryLineHandler(mailAutoresponderTelegram);
}
@Bean
@ConditionalOnBean(ChatMailAutoresponderTelegram.class)
public EventHandler<ChatMail> chatStoryLineHandler(ChatMailAutoresponderTelegram mailAutoresponderTelegram) {
return new ChatStoryLineHandler(mailAutoresponderTelegram);
}
@Bean
@ConditionalOnMissingBean(EventDispatching.class)
public EventDispatching eventDispatching(List<EventHandler> eventHandlers) {
return new EventDispatchingImpl(eventHandlers);
}
@Bean
@ConditionalOnBean(EventDispatching.class)
@ConditionalOnMissingBean(EventDistributor.class)
public EventDistributor eventDistributor(
TelegramConnect telegramConnect, EventDispatching eventDispatching
) {
return new EventDistributorService(telegramConnect, eventDispatching);
}
}

View File

@ -1,15 +1,13 @@
package dev.struchkov.godfather.telegram.starter.config;
import dev.struchkov.godfather.simple.context.repository.PersonSettingRepository;
import dev.struchkov.godfather.simple.context.repository.StorylineContext;
import dev.struchkov.godfather.simple.context.repository.StorylineRepository;
import dev.struchkov.godfather.simple.context.repository.StorylineHistoryRepository;
import dev.struchkov.godfather.simple.context.repository.UnitPointerRepository;
import dev.struchkov.godfather.simple.core.service.StorylineContextMapImpl;
import dev.struchkov.godfather.simple.data.repository.impl.PersonSettingLocalRepository;
import dev.struchkov.godfather.simple.data.repository.impl.StorylineMapRepository;
import dev.struchkov.godfather.simple.data.repository.impl.StorylineMapHistoryRepository;
import dev.struchkov.godfather.simple.data.repository.impl.UnitPointLocalRepository;
import dev.struchkov.godfather.telegram.simple.context.repository.SenderRepository;
import dev.struchkov.godfather.telegram.simple.core.TelegramConnectBot;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramConnect;
import dev.struchkov.godfather.telegram.simple.core.service.SenderMapRepository;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -22,24 +20,18 @@ import org.springframework.context.annotation.Configuration;
public class TelegramBotDataConfiguration {
@Bean
@ConditionalOnBean(TelegramConnectBot.class)
@ConditionalOnBean(TelegramConnect.class)
@ConditionalOnMissingBean(UnitPointerRepository.class)
public UnitPointerRepository unitPointerRepository() {
return new UnitPointLocalRepository();
}
@Bean
@ConditionalOnBean(TelegramConnectBot.class)
@ConditionalOnMissingBean(PersonSettingRepository.class)
public PersonSettingRepository personSettingRepository() {
return new PersonSettingLocalRepository();
}
@Bean
@ConditionalOnBean(TelegramConnectBot.class)
@ConditionalOnMissingBean(StorylineRepository.class)
public StorylineRepository storylineRepository() {
return new StorylineMapRepository();
@ConditionalOnBean(TelegramConnect.class)
@ConditionalOnMissingBean(StorylineHistoryRepository.class)
public StorylineHistoryRepository storylineHistoryRepository() {
return new StorylineMapHistoryRepository();
}
@Bean
@ -49,7 +41,7 @@ public class TelegramBotDataConfiguration {
}
@Bean
@ConditionalOnBean(TelegramConnectBot.class)
@ConditionalOnBean(TelegramConnect.class)
public StorylineContext storylineContext() {
return new StorylineContextMapImpl();
}

View File

@ -2,8 +2,10 @@ package dev.struchkov.godfather.telegram.starter.config;
import dev.struchkov.godfather.telegram.domain.config.ProxyConfig;
import dev.struchkov.godfather.telegram.domain.config.TelegramBotConfig;
import dev.struchkov.godfather.telegram.main.core.TelegramDefaultConnect;
import dev.struchkov.godfather.telegram.simple.core.TelegramConnectBot;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramConnect;
import dev.struchkov.godfather.telegram.simple.core.TelegramDefaultConnect;
import dev.struchkov.godfather.telegram.simple.core.TelegramPollingConnect;
import dev.struchkov.godfather.telegram.simple.core.TelegramWebhookConnect;
import dev.struchkov.godfather.telegram.starter.property.TelegramBotAutoresponderProperty;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -49,13 +51,20 @@ public class TelegramBotPropertyConfiguration {
@Bean
@Primary
@ConditionalOnProperty(prefix = "telegram.bot", name = "username")
public TelegramConnectBot telegramConnectBot(TelegramBotConfig telegramConfig) {
return new TelegramConnectBot(telegramConfig);
public TelegramConnect telegramConnectBot(TelegramBotConfig telegramConfig) {
return new TelegramPollingConnect(telegramConfig);
}
@Bean
@Primary
@ConditionalOnProperty(prefix = "telegram.bot", name = "webhook-url")
public TelegramConnect telegramWebhookConnect(TelegramBotConfig telegramConfig) {
return new TelegramWebhookConnect(telegramConfig);
}
@Bean
@ConditionalOnProperty(prefix = "telegram.bot", name = "token")
public TelegramDefaultConnect telegramDefaultConnect(TelegramBotConfig telegramConfig) {
public TelegramConnect telegramDefaultConnect(TelegramBotConfig telegramConfig) {
return new TelegramDefaultConnect(telegramConfig);
}