leaveChat method added

This commit is contained in:
aiden 2016-10-09 23:27:08 +03:30
parent 30d20b61f4
commit 08ec8d756a

27
bot.go
View File

@ -651,6 +651,33 @@ func (b *Bot) GetFile(fileID string) (File, error) {
return responseRecieved.Result, nil return responseRecieved.Result, nil
} }
// Use this method for your bot to leave a group, supergroup or channel. Returns True on success.
func (b *Bot) LeaveChat(recipient Recipient) (bool, error) {
params := map[string]string{
"chat_id": recipient.Destination(),
}
responseJSON, err := sendCommand("leaveChat", b.Token, params)
if err != nil {
return false, err
}
var responseRecieved struct {
Ok bool
Result bool
}
err = json.Unmarshal(responseJSON, &responseRecieved)
if err != nil {
return false, err
}
if !responseRecieved.Ok {
return false, fmt.Errorf("telebot: leavechat failure %s", responseRecieved.Result)
}
return responseRecieved.Result, nil
}
// GetFileDirectURL returns direct url for files using FileId which you can get from File object // GetFileDirectURL returns direct url for files using FileId which you can get from File object
func (b *Bot) GetFileDirectURL(fileID string) (string, error) { func (b *Bot) GetFileDirectURL(fileID string) (string, error) {
f, err := b.GetFile(fileID) f, err := b.GetFile(fileID)