1
0
mirror of synced 2024-11-22 12:26:02 +03:00

fix nickname

This commit is contained in:
Alex Lushpai 2018-06-15 14:09:52 +03:00
parent cd7486d6c4
commit 154a5d61b4

View File

@ -77,9 +77,13 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
if update.Message != nil { if update.Message != nil {
if update.Message.Text != "" { if update.Message.Text != "" {
nickname := update.Message.From.UserName
user := getUserByExternalID(update.Message.From.ID) user := getUserByExternalID(update.Message.From.ID)
if update.Message.From.UserName == "" {
nickname = update.Message.From.FirstName
}
if user.Expired(config.UpdateInterval) || user.ID == 0 { if user.Expired(config.UpdateInterval) || user.ID == 0 {
fileID, fileURL, err := GetFileIDAndURL(b.Token, update.Message.From.ID) fileID, fileURL, err := GetFileIDAndURL(b.Token, update.Message.From.ID)
if err != nil { if err != nil {
@ -130,7 +134,7 @@ func telegramWebhookHandler(w http.ResponseWriter, r *http.Request, token string
}, },
User: v1.User{ User: v1.User{
ExternalID: strconv.Itoa(update.Message.From.ID), ExternalID: strconv.Itoa(update.Message.From.ID),
Nickname: update.Message.From.UserName, Nickname: nickname,
Firstname: update.Message.From.FirstName, Firstname: update.Message.From.FirstName,
Avatar: user.UserPhotoURL, Avatar: user.UserPhotoURL,
Lastname: update.Message.From.LastName, Lastname: update.Message.From.LastName,