Use BaseChat to simplify Chat configurations
masterInstead of manually defining fields like ChatID, ChannelUsername, ReplyToMessageID, ReplyMarkup, and DisableNotification for every message-related endpoint, you can embed the BaseChat struct into your custom configuration.
Embedding BaseChat automatically provides these fields and its implementation of the params() method. You can then extend the params() method by calling the embedded base method first.
type MessageConfig struct {
BaseChat
Text string
ParseMode string
DisableWebPagePreview bool
}
func (config MessageConfig) params() (Params, error) {
params, err := config.BaseChat.params()
if err != nil {
return params, err
}
params.AddNonEmpty("text", config.Text)
return params, nil
}type MessageConfig struct {
BaseChat
Text string
ParseMode string
DisableWebPagePreview bool
}
func (config MessageConfig) params() (Params, error) {
params, err := config.BaseChat.params()
if err != nil {
return params, err
}
params.AddNonEmpty("text", config.Text)
// Add your other fields
return params, nil
}