From 154a5d61b40e677bab4e6f08b65a244cd9d94ffa Mon Sep 17 00:00:00 2001 From: Alex Lushpai Date: Fri, 15 Jun 2018 14:09:52 +0300 Subject: [PATCH] fix nickname --- telegram.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/telegram.go b/telegram.go index 391b3cc..95f9237 100644 --- a/telegram.go +++ b/telegram.go @@ -77,9 +77,13 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string if update.Message != nil { if update.Message.Text != "" { - + nickname := update.Message.From.UserName user := getUserByExternalID(update.Message.From.ID) + if update.Message.From.UserName == "" { + nickname = update.Message.From.FirstName + } + if user.Expired(config.UpdateInterval) || user.ID == 0 { fileID, fileURL, err := GetFileIDAndURL(b.Token, update.Message.From.ID) if err != nil { @@ -130,7 +134,7 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string }, User: v1.User{ ExternalID: strconv.Itoa(update.Message.From.ID), - Nickname: update.Message.From.UserName, + Nickname: nickname, Firstname: update.Message.From.FirstName, Avatar: user.UserPhotoURL, Lastname: update.Message.From.LastName,