add setChatTitle and setChatDescription methods
parent
5435d1d8ea
commit
6e69f99d11
24
bot.go
24
bot.go
|
@ -898,3 +898,27 @@ func (bot *BotAPI) UnpinChatMessage(config UnpinChatMessageConfig) (APIResponse,
|
|||
|
||||
return bot.MakeRequest(config.method(), v)
|
||||
}
|
||||
|
||||
// SetChatTitle change title of chat.
|
||||
func (bot *BotAPI) SetChatTitle(config SetChatTitleConfig) (APIResponse, error) {
|
||||
v, err := config.values()
|
||||
if err != nil {
|
||||
return APIResponse{}, err
|
||||
}
|
||||
|
||||
bot.debugLog(config.method(), v, nil)
|
||||
|
||||
return bot.MakeRequest(config.method(), v)
|
||||
}
|
||||
|
||||
// SetChatDescription change description of chat.
|
||||
func (bot *BotAPI) SetChatDescription(config SetChatDescriptionConfig) (APIResponse, error) {
|
||||
v, err := config.values()
|
||||
if err != nil {
|
||||
return APIResponse{}, err
|
||||
}
|
||||
|
||||
bot.debugLog(config.method(), v, nil)
|
||||
|
||||
return bot.MakeRequest(config.method(), v)
|
||||
}
|
||||
|
|
38
configs.go
38
configs.go
|
@ -1073,3 +1073,41 @@ func (config UnpinChatMessageConfig) values() (url.Values, error) {
|
|||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// SetChatTitleConfig contains information for change chat title.
|
||||
type SetChatTitleConfig struct {
|
||||
ChatID int64
|
||||
Title string
|
||||
}
|
||||
|
||||
func (config SetChatTitleConfig) method() string {
|
||||
return "setChatTitle"
|
||||
}
|
||||
|
||||
func (config SetChatTitleConfig) values() (url.Values, error) {
|
||||
v := url.Values{}
|
||||
|
||||
v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))
|
||||
v.Add("title", config.Title)
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// SetChatDescriptionConfig contains information for change chat description.
|
||||
type SetChatDescriptionConfig struct {
|
||||
ChatID int64
|
||||
Description string
|
||||
}
|
||||
|
||||
func (config SetChatDescriptionConfig) method() string {
|
||||
return "setChatDescription"
|
||||
}
|
||||
|
||||
func (config SetChatDescriptionConfig) values() (url.Values, error) {
|
||||
v := url.Values{}
|
||||
|
||||
v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))
|
||||
v.Add("description", config.Description)
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue