aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/api/TelegramBotHook.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/com/juick/api/TelegramBotHook.java b/src/main/java/com/juick/api/TelegramBotHook.java
index 8c23973e..ccfa2c11 100644
--- a/src/main/java/com/juick/api/TelegramBotHook.java
+++ b/src/main/java/com/juick/api/TelegramBotHook.java
@@ -149,14 +149,18 @@ public class TelegramBotHook {
User user_from = UserQueries.getUserByUID(jdbc, getUser(message.chat().id())).orElse(new User());
logger.info(String.format("got telegram msg %s from juick user %d", message.toString(), user_from.getUID()));
List<Long> chats = getChats();
+ String username = message.from().username();
+ if (username == null) {
+ username = message.from().firstName();
+ }
if (!chats.contains(message.chat().id())) {
addChat(message.chat().id());
- logger.info("added chat with " + message.from().firstName());
- createTelegramUser(message.from().id(), message.from().username());
- telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), message.from().username()));
+ logger.info("added chat with " + username);
+ createTelegramUser(message.from().id(), username);
+ telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), username));
} else {
if (user_from.getUID() == 0) {
- telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), message.from().username()));
+ telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), username));
} else if (message.text().equalsIgnoreCase("/login")) {
String msg = String.format("Hi, %s!\nTap to log in", user_from.getUName());
String msgUrl = "http://juick.com/login?" + UserQueries.getHashByUID(jdbc, user_from.getUID());