Skip to content

Commit

Permalink
Merge pull request #17 from tmpMeM/main
Browse files Browse the repository at this point in the history
debug
  • Loading branch information
dbidib authored Aug 9, 2024
2 parents 8c5e1c4 + 8914613 commit eb98259
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/db_data/bot_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ func SetUserFirstLastName(userID int64, firstLastName string) error {
// return fmt.Errorf("the firstLastName is NULL")
return nil
}
if firstLastName == "NULL" {
return AddKeyValueWithExpiration(
fmt.Sprintf("%s%d", USER_FirstLastName_prefix, userID),
firstLastName,
time.Hour*24,
)
}

return AddKeyValue(
fmt.Sprintf("%s%d", USER_FirstLastName_prefix, userID),
Expand Down
9 changes: 8 additions & 1 deletion internal/service/bot_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,18 @@ func GetUserFirstLastName(userID int64) string {
if len(firstLastName) == 0 {
if firstName, lastName, err := api.GetUserFirstLastName(userID); err != nil {
// firstLastName = "NULL"
log.Errorf("GetUserFirstLastName(%d): %v", userID, err)
log.Errorf("api.GetUserFirstLastName(%d): %v", userID, err)
} else {
firstLastName = firstName + " " + lastName
}
if err := SetUserFirstLastName(userID, firstLastName); err != nil {
log.Errorf("SetUserFirstLastName(%d,%s): %v", userID, firstLastName, err)
}
}

if firstLastName == "NULL" {
return ""
}
return firstLastName
}

Expand All @@ -106,5 +110,8 @@ func GetChatTitle(chatID int64) string {
log.Errorf("SetUserFirstLastName(%d,%s): %v", chatID, chatTitle, err)
}
}
if chatTitle == "NULL" {
return ""
}
return chatTitle
}

0 comments on commit eb98259

Please sign in to comment.