Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TRAC-6] Implement Message Service and basic Command Handling #7

Closed
wants to merge 2 commits into from

Conversation

OleksandrRym
Copy link
Collaborator

No description provided.

@OleksandrRym OleksandrRym changed the base branch from main to develop November 19, 2024 06:29
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.meta.generics.TelegramClient;

@Component
@RequiredArgsConstructor
@Getter

Choose a reason for hiding this comment

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

Why do you need this getter?

private final String command;
private final String description;

Command(String command, String description) {

Choose a reason for hiding this comment

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

You can use @requiredargsconstructor instead of creating manually constructor

@Getter
public enum Command {

START("/start", "Welcome to TrackMyCoin 📈💰!\nThis bot helps you track cryptocurrency prices\nand will send you notifications when your target price \nis reached.\n\nFor more information about the bot, type /info."),

Choose a reason for hiding this comment

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

Please move all static values (text) to application.yml

Choose a reason for hiding this comment

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

Also, please create task in Jira to move this values from application.yml to database. It will increase flexibility in changes for us

@Autowired
private TelegramBotClient telegramBotClient;

private final List<Command> commands = List.of(Command.START , Command.INFO , Command.HELP);

Choose a reason for hiding this comment

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

Please use strategy pattern

Choose a reason for hiding this comment

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

should be like this
commandProcessorsRegistry.getProcessor(Command).process(chatId)

try {
telegramBotClient.getTelegramClient().execute(message);
} catch (TelegramApiException e) {
e.printStackTrace();

Choose a reason for hiding this comment

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

never just print stack trace, you should use log

}
}

private void sendWelcomeMessage(Long chatId , String messageText) {

Choose a reason for hiding this comment

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

This is separate responsibility (SRP), not for MessageHandler
Move this method to telegramBotClient

@@ -0,0 +1,14 @@
FROM maven:3.9.4-eclipse-temurin-21-alpine as build

Choose a reason for hiding this comment

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

Shouldn't be here

@OleksandrRym OleksandrRym deleted the develop-addComand-start branch November 20, 2024 13:26
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.

2 participants