-
Notifications
You must be signed in to change notification settings - Fork 510
Description
1. User fields
telebot has an annoying problem in some update types, which stores the User object as a value, but not a pointer. If you want to use it as a Recipient, you have to take the pointer every time: b.Send(&q.From, ...). They are also differently named, while Message and Callback use Sender for the user.
type PollAnswer struct {
...
User User `json:"user"`
}type Query struct {
...
From User `json:"from"`
}My suggestion is to make them all Sender *User.
2. JSON tags
Some types have not json tags. Actually, we don't use them for making requests, but it's logical, that they display an original name as it defined in the Bot API documentation. I think it's better to fill all of them than to not.
3. Naming issues
type File struct {
FileID string `json:"file_id"`
UniqueID string `json:"file_unique_id"`
}type ChatPhoto struct {
SmallFileUniqueID string `json:"small_file_unique_id"`
BigFileUniqueID string `json:"big_file_unique_id"`
}I propose similarly with File omit File part in unique file IDs.
SmallFileUniqueID->SmallUniqueIDBigFileUniqueID->BigUniqueID
I also received feedback about sticker set function names:
func (b *Bot) UploadStickerFile(to Recipient, png *File) (*File, error)
func (b *Bot) CreateNewStickerSet(to Recipient, s StickerSet) error
func (b *Bot) AddStickerToSet(to Recipient, s Sticker) error
func (b *Bot) SetStickerPositionInSet(sticker string, position int) error
func (b *Bot) DeleteStickerFromSet(sticker string) errorUploadStickerFile->UploadStickerCreateNewStickerSet->CreateStickerSetAddStickerToSet->AddStickerSetStickerPositionInSet->SetStickerPositionDeleteStickerFromSet->DeleteSticker
4. Get in function names
Effective Go recommends not to use Get in function names.
I think we should remove this in our code as well:
b.GetWebhook()->b.Webhook()b.GetFile()->b.File()b.GetInviteLink()->b.InviteLink()b.GetCommands()->b.Commands()b.GetGameScores()->b.GameScores()b.GetStickerSet()->b.StickerSet()
- 1. Fixed
- 2. Fixed
- 3. Fixed
- 4. Fixed