Skip to content

Telegrambost springboot mapping starter#1493

Open
taragrammatonn wants to merge 20 commits intorubenlagus:devfrom
taragrammatonn:mappingstarter
Open

Telegrambost springboot mapping starter#1493
taragrammatonn wants to merge 20 commits intorubenlagus:devfrom
taragrammatonn:mappingstarter

Conversation

@taragrammatonn
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@yvasyliev yvasyliev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the whole change is about Bot Command mapping, I would name the module and related classes more specifically (e.g. telegrambots-springboot-longpolling-command-starter)

Comment on lines +30 to +34
@Bean
@ConditionalOnMissingBean
public OkHttpClient okHttpClient() {
return new OkHttpClient();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is OkHttpClient bean created but never used?

}

@Bean
public SpringLongPollingBot springLongPollingBot(TelegramBotProperties properties,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add @ConditionalOnMissingBean for extension opportunity

Comment on lines +52 to +64
@Bean
@ConditionalOnMissingBean(TelegramBotsLongPollingApplication.class)
public TelegramBotsLongPollingApplication telegramBotsApplication() {
return new TelegramBotsLongPollingApplication();
}

@Bean
@ConditionalOnMissingBean
public TelegramBotInitializer telegramBotInitializer(TelegramBotsLongPollingApplication telegramBotsApplication,
ObjectProvider<List<SpringLongPollingBot>> longPollingBots) {
return new TelegramBotInitializer(telegramBotsApplication,
longPollingBots.getIfAvailable(Collections::emptyList));
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since telegrambots-springboot-longpolling-starter is transitively included into into telegrambost-springboot-mapping-starter, no need to define TelegramBotsLongPollingApplication & TelegramBotInitializer beans explicitly

Comment on lines +26 to +29
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spring-boot-starter dependency is redundant in this module

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Missing value attribute.
  2. I believe the alias should be commands instead of command.

BotRequestMapping annotation = AnnotationUtils.findAnnotation(method, BotRequestMapping.class);
if (annotation != null) {
for (String command : annotation.value()) {
handlers.put(command, new BotHandlerMethod(bean, method));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check if a method has exactly one parameter of Update?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be a record

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unused/duplicated imports

}

public void handleUpdate(Update update) {
if (update.hasMessage() && update.getMessage().hasText()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's Message.isCommand() method

<version>8.2.0</version>
</parent>

<artifactId>telegrambost-springboot-mapping-starter</artifactId>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: telegrambots

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants