1
0
Fork 0

Added getChatMember method

This commit is contained in:
Maxim Lebedev 2017-09-05 00:47:27 +05:00
parent b56e7ca916
commit ecfcf2068b
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
1 changed files with 33 additions and 0 deletions

33
get_chat_member.go Normal file
View File

@ -0,0 +1,33 @@
package telegram
import (
"errors"
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// GetChatMember get information about a member of a chat. Returns a ChatMember object on success.
func (bot *Bot) GetChatMember(chat interface{}, user int) (*ChatMember, error) {
var args http.Args
args.Add("user_id", strconv.Itoa(user)) // Unique identifier of the target user
switch id := chatID.(type) {
case int64: // Unique identifier for the target chat...
args.Add("chat_id", strconv.FormatInt(id, 10))
case string: // ...or username of the target supergroup or channel (in the format @channelusername)
args.Add("chat_id", id)
default:
return nil, errors.New(errorInt64OrString)
}
resp, err := bot.get("getChatMember", &args)
if err != nil {
return nil, err
}
var data ChatMember
err = json.Unmarshal(*resp.Result, &data)
return &data, err
}