forked from Sanders/TelegaBot
Fix small
This commit is contained in:
@@ -78,11 +78,12 @@ public class KeyboardHelper {
|
||||
row2.add(new KeyboardButton(EDIT_BOOKS));
|
||||
|
||||
KeyboardRow row3 = new KeyboardRow();
|
||||
row1.add(new KeyboardButton(SET_BOOKS_GOAL));
|
||||
row2.add(new KeyboardButton(BACK));
|
||||
row3.add(new KeyboardButton(SET_BOOKS_GOAL2));
|
||||
row3.add(new KeyboardButton(BACK));
|
||||
|
||||
keyboardRows.add(row1);
|
||||
keyboardRows.add(row2);
|
||||
keyboardRows.add(row3);
|
||||
|
||||
ReplyKeyboardMarkup keyboardMarkup = new ReplyKeyboardMarkup(keyboardRows);
|
||||
keyboardMarkup.setResizeKeyboard(true);
|
||||
|
||||
@@ -6,4 +6,6 @@ import ru.cathub.telegabot.exception.ServiceException;
|
||||
public interface ProfileService {
|
||||
void enterProfileEditingMode(BotUser user);
|
||||
void handleProfileUpdate(BotUser user, String input) throws ServiceException;
|
||||
|
||||
void handleBooksGoalUpdate(BotUser user);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import ru.cathub.telegabot.service.ProfileService;
|
||||
import ru.cathub.telegabot.service.TelegramClientService;
|
||||
import ru.cathub.telegabot.utils.Constants;
|
||||
|
||||
import java.util.Optional;
|
||||
import static ru.cathub.telegabot.utils.Constants.SET_BOOKS_GOAL;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -43,15 +43,17 @@ public class ProfileServiceImpl implements ProfileService {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBooksGoalUpdate(BotUser user) {
|
||||
@Override
|
||||
public void handleBooksGoalUpdate(BotUser user) {
|
||||
user.setWorkingMode(BotUser.WorkingMode.EDIT_PROFILE);
|
||||
userRepository.save(user);
|
||||
telegramClientService.sendMessage(
|
||||
user,
|
||||
"Текущая цель: " + user.getBooksToRead() + "\nВведите новое количество книг:",
|
||||
KeyboardHelper.getBackKeyboard()
|
||||
"Текущая цель: " + user.getBooksToRead() + "\nВведите новое количество книг:"
|
||||
);
|
||||
}
|
||||
|
||||
private void processFieldUpdate(BotUser user, String input) {
|
||||
private void processFieldUpdate(BotUser user, String input) throws ServiceException {
|
||||
try {
|
||||
int goal = Integer.parseInt(input);
|
||||
if (goal < 0) throw new NumberFormatException();
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TelegramBotServiceImpl implements TelegramBotService {
|
||||
bookManageService.processBookInput(botUser,text);
|
||||
break;
|
||||
case SET_BOOKS_GOAL:
|
||||
profileService.handleProfileUpdate(botUser, text);
|
||||
profileService.handleBooksGoalUpdate(botUser);
|
||||
break;
|
||||
default:
|
||||
switch (botUser.getWorkingMode()) {
|
||||
|
||||
Reference in New Issue
Block a user