Добавил логирование инициализации вебхука
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Struchkov Mark 2023-03-19 17:49:22 +03:00
parent be8d9a3c82
commit c2d9b5db78
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6
5 changed files with 28 additions and 4 deletions

View File

@ -15,10 +15,7 @@ public class TelegramWebhookConnect implements TelegramConnect {
private TelegramWebhookBot webhookBot; private TelegramWebhookBot webhookBot;
public TelegramWebhookConnect(TelegramBotConfig telegramBotConfig) { public TelegramWebhookConnect(TelegramBotConfig telegramBotConfig) {
initWebHook(telegramBotConfig); log.info("Инициализация webhook соединения. {}", telegramBotConfig.getWebhookConfig());
}
private void initWebHook(TelegramBotConfig telegramBotConfig) {
try { try {
final TelegramWebhookBot bot = new TelegramWebhookBot(telegramBotConfig); final TelegramWebhookBot bot = new TelegramWebhookBot(telegramBotConfig);
final WebhookConfig webhookConfig = telegramBotConfig.getWebhookConfig(); final WebhookConfig webhookConfig = telegramBotConfig.getWebhookConfig();
@ -28,6 +25,7 @@ public class TelegramWebhookConnect implements TelegramConnect {
.build(); .build();
bot.setWebhook(setWebhook); bot.setWebhook(setWebhook);
webhookBot = bot; webhookBot = bot;
log.info("Инициализация webhook соединения прошла успешно.");
} }
} catch (TelegramApiException e) { } catch (TelegramApiException e) {
log.error(e.getMessage()); log.error(e.getMessage());

View File

@ -19,6 +19,7 @@ public class TelegramWebhookConnect implements TelegramConnect {
} }
private void initWebHook(TelegramBotConfig telegramBotConfig) { private void initWebHook(TelegramBotConfig telegramBotConfig) {
log.info("Инициализация webhook соединения. {}", telegramBotConfig.getWebhookConfig());
try { try {
final TelegramWebhookBot bot = new TelegramWebhookBot(telegramBotConfig); final TelegramWebhookBot bot = new TelegramWebhookBot(telegramBotConfig);
final WebhookConfig webhookConfig = telegramBotConfig.getWebhookConfig(); final WebhookConfig webhookConfig = telegramBotConfig.getWebhookConfig();
@ -28,6 +29,7 @@ public class TelegramWebhookConnect implements TelegramConnect {
.build(); .build();
bot.setWebhook(setWebhook); bot.setWebhook(setWebhook);
webhookBot = bot; webhookBot = bot;
log.info("Инициализация webhook соединения прошла успешно.");
} }
} catch (TelegramApiException e) { } catch (TelegramApiException e) {
log.error(e.getMessage()); log.error(e.getMessage());

View File

@ -2,6 +2,7 @@ package dev.struchkov.godfather.telegram.domain.config;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
/** /**
* TODO: Добавить описание класса. * TODO: Добавить описание класса.
@ -10,13 +11,24 @@ import lombok.Setter;
*/ */
@Getter @Getter
@Setter @Setter
@ToString
public class ProxyConfig { public class ProxyConfig {
private boolean enable = false; private boolean enable = false;
@ToString.Exclude
private String host; private String host;
@ToString.Exclude
private Integer port; private Integer port;
@ToString.Exclude
private String user; private String user;
@ToString.Exclude
private String password; private String password;
@ToString.Exclude
private Type type; private Type type;
public enum Type { public enum Type {

View File

@ -3,6 +3,7 @@ package dev.struchkov.godfather.telegram.domain.config;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
/** /**
* TODO: Добавить описание класса. * TODO: Добавить описание класса.
@ -11,10 +12,13 @@ import lombok.Setter;
*/ */
@Getter @Getter
@Setter @Setter
@ToString
@NoArgsConstructor @NoArgsConstructor
public class TelegramBotConfig { public class TelegramBotConfig {
private String username; private String username;
@ToString.Exclude
private String token; private String token;
private ProxyConfig proxyConfig; private ProxyConfig proxyConfig;

View File

@ -2,14 +2,22 @@ package dev.struchkov.godfather.telegram.domain.config;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
@Getter @Getter
@Setter @Setter
@ToString
public class WebhookConfig { public class WebhookConfig {
private boolean enable = false; private boolean enable = false;
@ToString.Exclude
private String rootUrl; private String rootUrl;
@ToString.Exclude
private String path; private String path;
@ToString.Exclude
private String accessKey; private String accessKey;
} }