telebot
telebot copied to clipboard
Get username by user id
I want to get username by user id
Here are what I'm trying to use:
b.Handle("/check", func(c tele.Context) error {
fmt.Println(c.Sender().ID)
u := &tele.User{ID: 123}
fmt.Println(u.Username)
return nil
})
```
As far as I know, you can't get username by user id. You should store username with user id somewhere if you want to get username by user id.
chat, err := b.ChatByID(893817263) if err != nil { fmt.Println(err) } fmt.Print("username:",chat.Username)