Skip to content

Commit 1faa35b

Browse files
committed
refactor
1 parent ce91e2d commit 1faa35b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

telegram-bot/src/main/java/project/vilsoncake/telegrambot/constant/MessageConst.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ public class MessageConst {
55
Hello, %s. Welcome to avgeek bot!
66
I will send you all wide-body aircraft flying into your airport, as well as An-124 alerts.
77
8-
For this, write the icao/iata code of your airport, you can get it on flightradar24.
8+
For this, write the icao/iata code of your airport, for example (waw) - Warsaw Chopin Airport.
9+
You can get it on flightradar24.
910
""";
10-
public static final String CHOOSE_AIRPORT_TEXT = "Great! How your airport is %s.";
11+
public static final String CHOOSE_AIRPORT_TEXT = "Great! Now your airport is %s.";
1112
public static final String CHANGE_AIRPORT_TEXT = "Write the icao/iata code of your airport, you can get it on flightradar24.";
12-
public static final String CURRENT_AIRPORT_TEXT = "Your current airport is: %s (%s)";
13+
public static final String CURRENT_AIRPORT_TEXT = "Your current airport is: %s (%s).";
1314
public static final String INVALID_AIRPORT_CODE_TEXT = "The code \"%s\" is invalid, make sure you didn't make a typo.";
15+
public static final String USER_CANNOT_CHOOSE_AIRPORT_TEXT = "You have not yet selected an airport, please write its iata/icao code.";
1416
public static final String FLIGHT_TEXT = """
1517
Flight to your airport from %s.
1618
Aircraft: %s
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package project.vilsoncake.telegrambot.constant;
22

33
public class TimeConst {
4-
public static final int FLIGHT_CHECK_DELAY_IN_MINUTES = 15;
4+
public static final int FLIGHT_CHECK_DELAY_IN_MINUTES = 10;
55
}

telegram-bot/src/main/java/project/vilsoncake/telegrambot/service/impl/BotServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ public SendMessage changeUserAirportCommand(String username, Long chatId) {
6161

6262
@Override
6363
public SendMessage getUserAirportCommand(String username, Long chatId) {
64+
if (userService.getUserByUsername(username).getState().equals(UserState.CHOOSING_AIRPORT)) {
65+
SendMessage message = new SendMessage();
66+
message.setChatId(chatId);
67+
message.setText(MessageConst.USER_CANNOT_CHOOSE_AIRPORT_TEXT);
68+
69+
return message;
70+
}
71+
6472
String airportCode = userService.getUserByUsername(username).getAirport();
6573

6674
AirportNameDto airportNameDto = webClient.get()

0 commit comments

Comments
 (0)