telebot icon indicating copy to clipboard operation
telebot copied to clipboard

Get username by user id

Open hlee4real opened this issue 1 year ago • 1 comments

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
	})
	```

hlee4real avatar Mar 26 '24 04:03 hlee4real

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.

codeheroo avatar Jun 27 '24 23:06 codeheroo

chat, err := b.ChatByID(893817263) if err != nil { fmt.Println(err) } fmt.Print("username:",chat.Username)

Wenw97 avatar Jul 30 '24 09:07 Wenw97