all repos — telegram-bot-api @ 6e69f99d113a3ac6537961e7ea3e1b1160f688eb

Golang bindings for the Telegram Bot API

add setChatTitle and setChatDescription methods
Oleksandr Savchuk mrxlinch@gmail.com
Sat, 03 Mar 2018 20:20:03 +0200
commit

6e69f99d113a3ac6537961e7ea3e1b1160f688eb

parent

5435d1d8eaf19425b40aebf050f5fda3280c00cc

2 files changed, 65 insertions(+), 3 deletions(-)

jump to
M bot.gobot.go

@@ -898,3 +898,27 @@ bot.debugLog(config.method(), v, nil)

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) +}
M configs.goconfigs.go

@@ -1038,8 +1038,8 @@ }

// PinChatMessageConfig contains information of a message in a chat to pin. type PinChatMessageConfig struct { - ChatID int64 - MessageID int + ChatID int64 + MessageID int DisableNotification bool }

@@ -1072,4 +1072,42 @@

v.Add("chat_id", strconv.FormatInt(config.ChatID, 10)) 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 +}