1
0
telegram/leave_chat.go

24 lines
490 B
Go
Raw Normal View History

2017-09-04 20:31:41 +00:00
package telegram
import (
2017-09-04 20:54:28 +00:00
"strconv"
2017-09-04 20:31:41 +00:00
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// LeaveChat leave a group, supergroup or channel. Returns True on success.
func (bot *Bot) LeaveChat(chat int64) (bool, error) {
2017-09-04 20:31:41 +00:00
var args http.Args
args.Add("chat_id", strconv.FormatInt(chat, 10))
2017-09-04 20:31:41 +00:00
2017-09-05 09:20:10 +00:00
resp, err := bot.request(nil, "leaveChat", &args)
2017-09-04 20:31:41 +00:00
if err != nil {
2017-09-04 20:54:28 +00:00
return false, err
2017-09-04 20:31:41 +00:00
}
var data bool
err = json.Unmarshal(*resp.Result, &data)
return data, err
}