mirror of
https://github.com/tucnak/telebot
synced 2024-11-11 01:10:39 +00:00
leaveChat method added
This commit is contained in:
parent
30d20b61f4
commit
08ec8d756a
27
bot.go
27
bot.go
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user