From 5074529a1164f4b34a7f78c78a9de1c79ccdd3de Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Tue, 7 Apr 2020 02:46:08 +0300 Subject: [PATCH 1/9] chat getinfo and sendActions --- bot.go | 6 ++++ chat.go | 59 +++++++++++++++++++++++++++++++++++--- chat_easyjson.go | 56 +++++++++++++++++++++++++++++++----- client.go | 27 ++++++++++++++++-- types.go | 5 ++++ types_easyjson.go | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 213 insertions(+), 13 deletions(-) diff --git a/bot.go b/bot.go index 7d0aa9d..8b4ac0a 100644 --- a/bot.go +++ b/bot.go @@ -39,6 +39,12 @@ func (b *Bot) GetChatInfo(chatID string) (*Chat, error) { return b.client.GetChatInfo(chatID) } +// GetChatInfo returns information about chat: +// id, type, title, public, group, inviteLink, admins +func (b *Bot) SendChatActions(chatID string, actions ...ChatAction) error { + return b.client.SendChatActions(chatID, actions...) +} + // GetFileInfo returns information about file: // id, type, size, filename, url func (b *Bot) GetFileInfo(fileID string) (*File, error) { diff --git a/chat.go b/chat.go index 8095b1f..3cfc6e5 100644 --- a/chat.go +++ b/chat.go @@ -1,14 +1,49 @@ package botgolang +import "fmt" + //go:generate easyjson -all chat.go +type ChatAction = string + +const ( + TypingAction ChatAction = "typing" + LookingAction ChatAction = "looking" +) + +type ChatType = string + +const ( + Private ChatType = "private" + Group ChatType = "group" + Channel ChatType = "channel" +) + type Chat struct { client *Client // Id of the chat ID string `json:"chatId"` - // Type of the chat: channel or group - Type string `json:"type"` + // Type of the chat: channel, group or private + Type ChatType `json:"type"` + + // First name of the user + FirstName string `json:"firstName"` + + // Last name of the user + LastName string `json:"lastName"` + + // Nick of the user + Nick string `json:"nick"` + + // User about or group/channel description + About string `json:"about"` + + // Rules of the group/channel + Rules string `json:"rules"` + + // Flag that indicates that requested chat is the bot + IsBot bool `json:"isBot"` // Title of the chat Title string `json:"title"` @@ -16,10 +51,26 @@ type Chat struct { // Is this chat public? Public bool `json:"public"` - Group string `json:"group"` + // Is this chat has join moderation? + JoinModeration bool `json:"joinModeration"` // You can send this link to all your friends InviteLink string `json:"inviteLink"` - Admins []Contact `json:"admins"` + // Chat admins list + Admins []Admin `json:"admins"` +} + +func (c *Chat) resolveID() string { + switch c.Type { + case Private: + return c.Nick + default: + return c.ID + } +} + +func (c *Chat) SendActions(actions ...ChatAction) error { + fmt.Println(c.resolveID()) + return c.client.SendChatActions(c.resolveID(), actions...) } diff --git a/chat_easyjson.go b/chat_easyjson.go index f0d23d7..41caa3f 100644 --- a/chat_easyjson.go +++ b/chat_easyjson.go @@ -40,12 +40,24 @@ func easyjson9b8f5552DecodeGithubComMailRuImBotGolang(in *jlexer.Lexer, out *Cha out.ID = string(in.String()) case "type": out.Type = string(in.String()) + case "firstName": + out.FirstName = string(in.String()) + case "lastName": + out.LastName = string(in.String()) + case "nick": + out.Nick = string(in.String()) + case "about": + out.About = string(in.String()) + case "rules": + out.Rules = string(in.String()) + case "isBot": + out.IsBot = bool(in.Bool()) case "title": out.Title = string(in.String()) case "public": out.Public = bool(in.Bool()) - case "group": - out.Group = string(in.String()) + case "joinModeration": + out.JoinModeration = bool(in.Bool()) case "inviteLink": out.InviteLink = string(in.String()) case "admins": @@ -56,15 +68,15 @@ func easyjson9b8f5552DecodeGithubComMailRuImBotGolang(in *jlexer.Lexer, out *Cha in.Delim('[') if out.Admins == nil { if !in.IsDelim(']') { - out.Admins = make([]Contact, 0, 1) + out.Admins = make([]Admin, 0, 2) } else { - out.Admins = []Contact{} + out.Admins = []Admin{} } } else { out.Admins = (out.Admins)[:0] } for !in.IsDelim(']') { - var v1 Contact + var v1 Admin (v1).UnmarshalEasyJSON(in) out.Admins = append(out.Admins, v1) in.WantComma() @@ -95,6 +107,36 @@ func easyjson9b8f5552EncodeGithubComMailRuImBotGolang(out *jwriter.Writer, in Ch out.RawString(prefix) out.String(string(in.Type)) } + { + const prefix string = ",\"firstName\":" + out.RawString(prefix) + out.String(string(in.FirstName)) + } + { + const prefix string = ",\"lastName\":" + out.RawString(prefix) + out.String(string(in.LastName)) + } + { + const prefix string = ",\"nick\":" + out.RawString(prefix) + out.String(string(in.Nick)) + } + { + const prefix string = ",\"about\":" + out.RawString(prefix) + out.String(string(in.About)) + } + { + const prefix string = ",\"rules\":" + out.RawString(prefix) + out.String(string(in.Rules)) + } + { + const prefix string = ",\"isBot\":" + out.RawString(prefix) + out.Bool(bool(in.IsBot)) + } { const prefix string = ",\"title\":" out.RawString(prefix) @@ -106,9 +148,9 @@ func easyjson9b8f5552EncodeGithubComMailRuImBotGolang(out *jwriter.Writer, in Ch out.Bool(bool(in.Public)) } { - const prefix string = ",\"group\":" + const prefix string = ",\"joinModeration\":" out.RawString(prefix) - out.String(string(in.Group)) + out.Bool(bool(in.JoinModeration)) } { const prefix string = ",\"inviteLink\":" diff --git a/client.go b/client.go index 8a28d06..ac0f334 100644 --- a/client.go +++ b/client.go @@ -127,12 +127,15 @@ func (c *Client) GetChatInfo(chatID string) (*Chat, error) { return nil, fmt.Errorf("error while receiving information: %s", err) } - chat := &Chat{} + chat := &Chat{ + client: c, + ID: chatID, + } if err := json.Unmarshal(response, chat); err != nil { return nil, fmt.Errorf("error while unmarshalling information: %s", err) } - if chat.Group != "group" { + if chat.Type == Private { return chat, nil } @@ -148,6 +151,26 @@ func (c *Client) GetChatInfo(chatID string) (*Chat, error) { return chat, nil } +func (c *Client) SendChatActions(chatID string, actions ...ChatAction) error { + actionsMap := make(map[ChatAction]bool) + filteredActions := make([]ChatAction, 0) + for _, action := range actions { + if _, has := actionsMap[action]; !has { + filteredActions = append(filteredActions, action) + actionsMap[action] = true + } + } + params := url.Values{ + "chatId": {chatID}, + "actions": filteredActions, + } + _, err := c.Do("/chats/sendActions", params, nil) + if err != nil { + return fmt.Errorf("error while receiving information: %s", err) + } + return nil +} + func (c *Client) GetFileInfo(fileID string) (*File, error) { params := url.Values{ "fileId": {fileID}, diff --git a/types.go b/types.go index 25445f9..b7c70f6 100644 --- a/types.go +++ b/types.go @@ -54,6 +54,11 @@ type eventsResponse struct { Events []*Event `json:"events"` } +type Admin struct { + UserID string `json:"userId"` + Creator bool `json:"creator"` +} + type Contact struct { UserID string `json:"userId"` FirstName string `json:"firstName"` diff --git a/types_easyjson.go b/types_easyjson.go index 76bcaea..7e54edf 100644 --- a/types_easyjson.go +++ b/types_easyjson.go @@ -1052,3 +1052,76 @@ func (v *BotInfo) UnmarshalJSON(data []byte) error { func (v *BotInfo) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(l, v) } +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(in *jlexer.Lexer, out *Admin) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "userId": + out.UserID = string(in.String()) + case "creator": + out.Creator = bool(in.Bool()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(out *jwriter.Writer, in Admin) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"userId\":" + out.RawString(prefix[1:]) + out.String(string(in.UserID)) + } + { + const prefix string = ",\"creator\":" + out.RawString(prefix) + out.Bool(bool(in.Creator)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Admin) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Admin) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Admin) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Admin) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(l, v) +} From 573b960d91212588b7bb9a664397848d2f881ec1 Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Tue, 7 Apr 2020 02:50:37 +0300 Subject: [PATCH 2/9] removed debug print --- chat.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/chat.go b/chat.go index 3cfc6e5..7c67ed7 100644 --- a/chat.go +++ b/chat.go @@ -1,7 +1,5 @@ package botgolang -import "fmt" - //go:generate easyjson -all chat.go type ChatAction = string @@ -71,6 +69,5 @@ func (c *Chat) resolveID() string { } func (c *Chat) SendActions(actions ...ChatAction) error { - fmt.Println(c.resolveID()) return c.client.SendChatActions(c.resolveID(), actions...) } From e9eab0a2c8155c5ba66f824afa0819b9a549c296 Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Wed, 8 Apr 2020 22:21:50 +0300 Subject: [PATCH 3/9] chat members and admins --- bot.go | 17 +- chat.go | 18 +- chat_easyjson.go | 39 --- client.go | 44 +++- types.go | 28 ++- types_easyjson.go | 595 +++++++++++++++++++++++++++++++++++++--------- updates.go | 2 +- 7 files changed, 567 insertions(+), 176 deletions(-) diff --git a/bot.go b/bot.go index 8b4ac0a..e879fb9 100644 --- a/bot.go +++ b/bot.go @@ -39,12 +39,23 @@ func (b *Bot) GetChatInfo(chatID string) (*Chat, error) { return b.client.GetChatInfo(chatID) } -// GetChatInfo returns information about chat: -// id, type, title, public, group, inviteLink, admins +// SendChatActions sends an actions like "typing, looking" func (b *Bot) SendChatActions(chatID string, actions ...ChatAction) error { return b.client.SendChatActions(chatID, actions...) } +// GetChatAdmins returns chat admins list with fields: +// userID, creator flag +func (b *Bot) GetChatAdmins(chatID string) ([]ChatMember, error) { + return b.client.GetChatAdmins(chatID) +} + +// GetChatMem returns chat members list with fields: +// userID, creator flag, admin flag +func (b *Bot) GetChatMembers(chatID string) ([]ChatMember, error) { + return b.client.GetChatMembers(chatID) +} + // GetFileInfo returns information about file: // id, type, size, filename, url func (b *Bot) GetFileInfo(fileID string) (*File, error) { @@ -114,7 +125,7 @@ func (b *Bot) NewMessageFromPart(message PartMessage) *Message { return &Message{ client: b.client, ID: message.MsgID, - Chat: Chat{ID: message.From.UserID, Title: message.From.FirstName}, + Chat: Chat{ID: message.From.User.ID, Title: message.From.FirstName}, Text: message.Text, Timestamp: message.Timestamp, } diff --git a/chat.go b/chat.go index 7c67ed7..3e441bd 100644 --- a/chat.go +++ b/chat.go @@ -54,9 +54,6 @@ type Chat struct { // You can send this link to all your friends InviteLink string `json:"inviteLink"` - - // Chat admins list - Admins []Admin `json:"admins"` } func (c *Chat) resolveID() string { @@ -68,6 +65,21 @@ func (c *Chat) resolveID() string { } } +// Send bot actions to the chat +// +// You can call this method every time you change the current actions, +// or every 10 seconds if the actions have not changed. After sending a +// request without active action, you should not re-notify of their absence. func (c *Chat) SendActions(actions ...ChatAction) error { return c.client.SendChatActions(c.resolveID(), actions...) } + +// Get chat administrators list +func (c *Chat) GetAdmins() ([]ChatMember, error) { + return c.client.GetChatAdmins(c.ID) +} + +// Get chat members list +func (c *Chat) GetMembers() ([]ChatMember, error) { + return c.client.GetChatMembers(c.ID) +} diff --git a/chat_easyjson.go b/chat_easyjson.go index 41caa3f..44cbdb0 100644 --- a/chat_easyjson.go +++ b/chat_easyjson.go @@ -60,29 +60,6 @@ func easyjson9b8f5552DecodeGithubComMailRuImBotGolang(in *jlexer.Lexer, out *Cha out.JoinModeration = bool(in.Bool()) case "inviteLink": out.InviteLink = string(in.String()) - case "admins": - if in.IsNull() { - in.Skip() - out.Admins = nil - } else { - in.Delim('[') - if out.Admins == nil { - if !in.IsDelim(']') { - out.Admins = make([]Admin, 0, 2) - } else { - out.Admins = []Admin{} - } - } else { - out.Admins = (out.Admins)[:0] - } - for !in.IsDelim(']') { - var v1 Admin - (v1).UnmarshalEasyJSON(in) - out.Admins = append(out.Admins, v1) - in.WantComma() - } - in.Delim(']') - } default: in.SkipRecursive() } @@ -157,22 +134,6 @@ func easyjson9b8f5552EncodeGithubComMailRuImBotGolang(out *jwriter.Writer, in Ch out.RawString(prefix) out.String(string(in.InviteLink)) } - { - const prefix string = ",\"admins\":" - out.RawString(prefix) - if in.Admins == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v2, v3 := range in.Admins { - if v2 > 0 { - out.RawByte(',') - } - (v3).MarshalEasyJSON(out) - } - out.RawByte(']') - } - } out.RawByte('}') } diff --git a/client.go b/client.go index ac0f334..98a3519 100644 --- a/client.go +++ b/client.go @@ -138,16 +138,6 @@ func (c *Client) GetChatInfo(chatID string) (*Chat, error) { if chat.Type == Private { return chat, nil } - - response, err = c.Do("/chats/getAdmins", params, nil) - if err != nil { - return nil, fmt.Errorf("error while receiving admins: %s", err) - } - - if err := json.Unmarshal(response, chat); err != nil { - return nil, fmt.Errorf("error while unmarshalling admins: %s", err) - } - return chat, nil } @@ -171,6 +161,40 @@ func (c *Client) SendChatActions(chatID string, actions ...ChatAction) error { return nil } +func (c *Client) GetChatAdmins(chatID string) ([]ChatMember, error) { + params := url.Values{ + "chatId": {chatID}, + } + + response, err := c.Do("/chats/getAdmins", params, nil) + if err != nil { + return nil, fmt.Errorf("error while receiving admins: %s", err) + } + + admins := new(AdminsListResponse) + if err := json.Unmarshal(response, admins); err != nil { + return nil, fmt.Errorf("error while unmarshalling admins: %s", err) + } + return admins.List, nil +} + +func (c *Client) GetChatMembers(chatID string) ([]ChatMember, error) { + params := url.Values{ + "chatId": {chatID}, + } + + response, err := c.Do("/chats/getMembers", params, nil) + if err != nil { + return nil, fmt.Errorf("error while receiving members: %s", err) + } + + members := new(MembersListResponse) + if err := json.Unmarshal(response, members); err != nil { + return nil, fmt.Errorf("error while unmarshalling members: %s", err) + } + return members.List, nil +} + func (c *Client) GetFileInfo(fileID string) (*File, error) { params := url.Values{ "fileId": {fileID}, diff --git a/types.go b/types.go index b7c70f6..ea72975 100644 --- a/types.go +++ b/types.go @@ -33,8 +33,7 @@ type Photo struct { } type BotInfo struct { - // Id of the bot - UserID string `json:"userId"` + User // Nickname of the bot Nick string `json:"nick"` @@ -54,13 +53,30 @@ type eventsResponse struct { Events []*Event `json:"events"` } -type Admin struct { - UserID string `json:"userId"` - Creator bool `json:"creator"` +type User struct { + ID string `json:"userId"` +} + +type ChatMember struct { + User + Creator bool `json:"creator"` + Admin bool `json:"admin"` +} + +type UsersListResponse struct { + List []User `json:"users"` +} + +type MembersListResponse struct { + List []ChatMember `json:"members"` +} + +type AdminsListResponse struct { + List []ChatMember `json:"admins"` } type Contact struct { - UserID string `json:"userId"` + User FirstName string `json:"firstName"` LastName string `json:"lastName"` } diff --git a/types_easyjson.go b/types_easyjson.go index 7e54edf..d5eacda 100644 --- a/types_easyjson.go +++ b/types_easyjson.go @@ -134,7 +134,171 @@ func (v *eventsResponse) UnmarshalJSON(data []byte) error { func (v *eventsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson6601e8cdDecodeGithubComMailRuImBotGolang(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang1(in *jlexer.Lexer, out *Response) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang1(in *jlexer.Lexer, out *UsersListResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "users": + if in.IsNull() { + in.Skip() + out.List = nil + } else { + in.Delim('[') + if out.List == nil { + if !in.IsDelim(']') { + out.List = make([]User, 0, 4) + } else { + out.List = []User{} + } + } else { + out.List = (out.List)[:0] + } + for !in.IsDelim(']') { + var v4 User + (v4).UnmarshalEasyJSON(in) + out.List = append(out.List, v4) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang1(out *jwriter.Writer, in UsersListResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"users\":" + out.RawString(prefix[1:]) + if in.List == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v5, v6 := range in.List { + if v5 > 0 { + out.RawByte(',') + } + (v6).MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v UsersListResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMailRuImBotGolang1(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v UsersListResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang1(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *UsersListResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMailRuImBotGolang1(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *UsersListResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang1(l, v) +} +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang2(in *jlexer.Lexer, out *User) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "userId": + out.ID = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang2(out *jwriter.Writer, in User) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"userId\":" + out.RawString(prefix[1:]) + out.String(string(in.ID)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v User) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMailRuImBotGolang2(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v User) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang2(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *User) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMailRuImBotGolang2(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *User) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang2(l, v) +} +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(in *jlexer.Lexer, out *Response) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -167,7 +331,7 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang1(in *jlexer.Lexer, out *Re in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang1(out *jwriter.Writer, in Response) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(out *jwriter.Writer, in Response) { out.RawByte('{') first := true _ = first @@ -187,27 +351,27 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang1(out *jwriter.Writer, in R // MarshalJSON supports json.Marshaler interface func (v Response) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang1(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Response) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang1(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Response) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang1(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Response) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang1(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang2(in *jlexer.Lexer, out *Photo) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(in *jlexer.Lexer, out *Photo) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -238,7 +402,7 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang2(in *jlexer.Lexer, out *Ph in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang2(out *jwriter.Writer, in Photo) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(out *jwriter.Writer, in Photo) { out.RawByte('{') first := true _ = first @@ -253,27 +417,27 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang2(out *jwriter.Writer, in P // MarshalJSON supports json.Marshaler interface func (v Photo) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang2(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Photo) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang2(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Photo) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang2(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Photo) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang2(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(in *jlexer.Lexer, out *PartPayload) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(in *jlexer.Lexer, out *PartPayload) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -316,7 +480,7 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(in *jlexer.Lexer, out *Pa in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(out *jwriter.Writer, in PartPayload) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(out *jwriter.Writer, in PartPayload) { out.RawByte('{') first := true _ = first @@ -361,27 +525,27 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(out *jwriter.Writer, in P // MarshalJSON supports json.Marshaler interface func (v PartPayload) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v PartPayload) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *PartPayload) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *PartPayload) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(in *jlexer.Lexer, out *PartMessage) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(in *jlexer.Lexer, out *PartMessage) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -418,7 +582,7 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(in *jlexer.Lexer, out *Pa in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(out *jwriter.Writer, in PartMessage) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(out *jwriter.Writer, in PartMessage) { out.RawByte('{') first := true _ = first @@ -448,27 +612,27 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(out *jwriter.Writer, in P // MarshalJSON supports json.Marshaler interface func (v PartMessage) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v PartMessage) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *PartMessage) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *PartMessage) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(in *jlexer.Lexer, out *Part) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(in *jlexer.Lexer, out *Part) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -501,7 +665,7 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(in *jlexer.Lexer, out *Pa in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(out *jwriter.Writer, in Part) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(out *jwriter.Writer, in Part) { out.RawByte('{') first := true _ = first @@ -521,27 +685,125 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(out *jwriter.Writer, in P // MarshalJSON supports json.Marshaler interface func (v Part) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Part) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Part) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Part) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(in *jlexer.Lexer, out *EventPayload) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang8(in *jlexer.Lexer, out *MembersListResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "members": + if in.IsNull() { + in.Skip() + out.List = nil + } else { + in.Delim('[') + if out.List == nil { + if !in.IsDelim(']') { + out.List = make([]ChatMember, 0, 2) + } else { + out.List = []ChatMember{} + } + } else { + out.List = (out.List)[:0] + } + for !in.IsDelim(']') { + var v7 ChatMember + (v7).UnmarshalEasyJSON(in) + out.List = append(out.List, v7) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang8(out *jwriter.Writer, in MembersListResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"members\":" + out.RawString(prefix[1:]) + if in.List == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v8, v9 := range in.List { + if v8 > 0 { + out.RawByte(',') + } + (v9).MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v MembersListResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMailRuImBotGolang8(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v MembersListResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang8(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *MembersListResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMailRuImBotGolang8(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *MembersListResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang8(l, v) +} +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(in *jlexer.Lexer, out *EventPayload) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -584,9 +846,9 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(in *jlexer.Lexer, out *Ev out.Parts = (out.Parts)[:0] } for !in.IsDelim(']') { - var v4 Part - (v4).UnmarshalEasyJSON(in) - out.Parts = append(out.Parts, v4) + var v10 Part + (v10).UnmarshalEasyJSON(in) + out.Parts = append(out.Parts, v10) in.WantComma() } in.Delim(']') @@ -609,9 +871,9 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(in *jlexer.Lexer, out *Ev out.LeftMembers = (out.LeftMembers)[:0] } for !in.IsDelim(']') { - var v5 Contact - (v5).UnmarshalEasyJSON(in) - out.LeftMembers = append(out.LeftMembers, v5) + var v11 Contact + (v11).UnmarshalEasyJSON(in) + out.LeftMembers = append(out.LeftMembers, v11) in.WantComma() } in.Delim(']') @@ -632,9 +894,9 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(in *jlexer.Lexer, out *Ev out.NewMembers = (out.NewMembers)[:0] } for !in.IsDelim(']') { - var v6 Contact - (v6).UnmarshalEasyJSON(in) - out.NewMembers = append(out.NewMembers, v6) + var v12 Contact + (v12).UnmarshalEasyJSON(in) + out.NewMembers = append(out.NewMembers, v12) in.WantComma() } in.Delim(']') @@ -653,7 +915,7 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(in *jlexer.Lexer, out *Ev in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(out *jwriter.Writer, in EventPayload) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(out *jwriter.Writer, in EventPayload) { out.RawByte('{') first := true _ = first @@ -684,11 +946,11 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(out *jwriter.Writer, in E out.RawString("null") } else { out.RawByte('[') - for v7, v8 := range in.Parts { - if v7 > 0 { + for v13, v14 := range in.Parts { + if v13 > 0 { out.RawByte(',') } - (v8).MarshalEasyJSON(out) + (v14).MarshalEasyJSON(out) } out.RawByte(']') } @@ -705,11 +967,11 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(out *jwriter.Writer, in E out.RawString("null") } else { out.RawByte('[') - for v9, v10 := range in.LeftMembers { - if v9 > 0 { + for v15, v16 := range in.LeftMembers { + if v15 > 0 { out.RawByte(',') } - (v10).MarshalEasyJSON(out) + (v16).MarshalEasyJSON(out) } out.RawByte(']') } @@ -721,11 +983,11 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(out *jwriter.Writer, in E out.RawString("null") } else { out.RawByte('[') - for v11, v12 := range in.NewMembers { - if v11 > 0 { + for v17, v18 := range in.NewMembers { + if v17 > 0 { out.RawByte(',') } - (v12).MarshalEasyJSON(out) + (v18).MarshalEasyJSON(out) } out.RawByte(']') } @@ -746,27 +1008,27 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(out *jwriter.Writer, in E // MarshalJSON supports json.Marshaler interface func (v EventPayload) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v EventPayload) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *EventPayload) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *EventPayload) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(in *jlexer.Lexer, out *Event) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(in *jlexer.Lexer, out *Event) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -801,7 +1063,7 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(in *jlexer.Lexer, out *Ev in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(out *jwriter.Writer, in Event) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(out *jwriter.Writer, in Event) { out.RawByte('{') first := true _ = first @@ -826,27 +1088,27 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(out *jwriter.Writer, in E // MarshalJSON supports json.Marshaler interface func (v Event) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Event) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Event) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Event) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang8(in *jlexer.Lexer, out *Contact) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang11(in *jlexer.Lexer, out *Contact) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -865,12 +1127,12 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang8(in *jlexer.Lexer, out *Co continue } switch key { - case "userId": - out.UserID = string(in.String()) case "firstName": out.FirstName = string(in.String()) case "lastName": out.LastName = string(in.String()) + case "userId": + out.ID = string(in.String()) default: in.SkipRecursive() } @@ -881,18 +1143,13 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang8(in *jlexer.Lexer, out *Co in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang8(out *jwriter.Writer, in Contact) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang11(out *jwriter.Writer, in Contact) { out.RawByte('{') first := true _ = first - { - const prefix string = ",\"userId\":" - out.RawString(prefix[1:]) - out.String(string(in.UserID)) - } { const prefix string = ",\"firstName\":" - out.RawString(prefix) + out.RawString(prefix[1:]) out.String(string(in.FirstName)) } { @@ -900,33 +1157,38 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang8(out *jwriter.Writer, in C out.RawString(prefix) out.String(string(in.LastName)) } + { + const prefix string = ",\"userId\":" + out.RawString(prefix) + out.String(string(in.ID)) + } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface func (v Contact) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang8(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang11(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Contact) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang8(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang11(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Contact) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang8(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang11(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Contact) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang8(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang11(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(in *jlexer.Lexer, out *BotInfo) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang12(in *jlexer.Lexer, out *ChatMember) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -945,8 +1207,86 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(in *jlexer.Lexer, out *Bo continue } switch key { + case "creator": + out.Creator = bool(in.Bool()) + case "admin": + out.Admin = bool(in.Bool()) case "userId": - out.UserID = string(in.String()) + out.ID = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang12(out *jwriter.Writer, in ChatMember) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"creator\":" + out.RawString(prefix[1:]) + out.Bool(bool(in.Creator)) + } + { + const prefix string = ",\"admin\":" + out.RawString(prefix) + out.Bool(bool(in.Admin)) + } + { + const prefix string = ",\"userId\":" + out.RawString(prefix) + out.String(string(in.ID)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v ChatMember) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMailRuImBotGolang12(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v ChatMember) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang12(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *ChatMember) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMailRuImBotGolang12(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *ChatMember) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang12(l, v) +} +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang13(in *jlexer.Lexer, out *BotInfo) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeString() + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { case "nick": out.Nick = string(in.String()) case "firstName": @@ -969,13 +1309,15 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(in *jlexer.Lexer, out *Bo out.Photo = (out.Photo)[:0] } for !in.IsDelim(']') { - var v13 Photo - (v13).UnmarshalEasyJSON(in) - out.Photo = append(out.Photo, v13) + var v19 Photo + (v19).UnmarshalEasyJSON(in) + out.Photo = append(out.Photo, v19) in.WantComma() } in.Delim(']') } + case "userId": + out.ID = string(in.String()) default: in.SkipRecursive() } @@ -986,18 +1328,13 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(in *jlexer.Lexer, out *Bo in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(out *jwriter.Writer, in BotInfo) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang13(out *jwriter.Writer, in BotInfo) { out.RawByte('{') first := true _ = first - { - const prefix string = ",\"userId\":" - out.RawString(prefix[1:]) - out.String(string(in.UserID)) - } { const prefix string = ",\"nick\":" - out.RawString(prefix) + out.RawString(prefix[1:]) out.String(string(in.Nick)) } { @@ -1017,42 +1354,47 @@ func easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(out *jwriter.Writer, in B out.RawString("null") } else { out.RawByte('[') - for v14, v15 := range in.Photo { - if v14 > 0 { + for v20, v21 := range in.Photo { + if v20 > 0 { out.RawByte(',') } - (v15).MarshalEasyJSON(out) + (v21).MarshalEasyJSON(out) } out.RawByte(']') } } + { + const prefix string = ",\"userId\":" + out.RawString(prefix) + out.String(string(in.ID)) + } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface func (v BotInfo) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang13(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v BotInfo) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang13(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *BotInfo) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang13(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *BotInfo) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang13(l, v) } -func easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(in *jlexer.Lexer, out *Admin) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang14(in *jlexer.Lexer, out *AdminsListResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1071,10 +1413,29 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(in *jlexer.Lexer, out *A continue } switch key { - case "userId": - out.UserID = string(in.String()) - case "creator": - out.Creator = bool(in.Bool()) + case "admins": + if in.IsNull() { + in.Skip() + out.List = nil + } else { + in.Delim('[') + if out.List == nil { + if !in.IsDelim(']') { + out.List = make([]ChatMember, 0, 2) + } else { + out.List = []ChatMember{} + } + } else { + out.List = (out.List)[:0] + } + for !in.IsDelim(']') { + var v22 ChatMember + (v22).UnmarshalEasyJSON(in) + out.List = append(out.List, v22) + in.WantComma() + } + in.Delim(']') + } default: in.SkipRecursive() } @@ -1085,43 +1446,49 @@ func easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(in *jlexer.Lexer, out *A in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(out *jwriter.Writer, in Admin) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang14(out *jwriter.Writer, in AdminsListResponse) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"userId\":" + const prefix string = ",\"admins\":" out.RawString(prefix[1:]) - out.String(string(in.UserID)) - } - { - const prefix string = ",\"creator\":" - out.RawString(prefix) - out.Bool(bool(in.Creator)) + if in.List == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v23, v24 := range in.List { + if v23 > 0 { + out.RawByte(',') + } + (v24).MarshalEasyJSON(out) + } + out.RawByte(']') + } } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v Admin) MarshalJSON() ([]byte, error) { +func (v AdminsListResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang14(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v Admin) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(w, v) +func (v AdminsListResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang14(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *Admin) UnmarshalJSON(data []byte) error { +func (v *AdminsListResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang14(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Admin) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(l, v) +func (v *AdminsListResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang14(l, v) } diff --git a/updates.go b/updates.go index 428b28d..5abb25b 100644 --- a/updates.go +++ b/updates.go @@ -29,7 +29,7 @@ func (u *Updater) NewMessageFromPayload(message EventPayload) *Message { return &Message{ client: u.client, ID: message.MsgID, - Chat: Chat{ID: message.From.UserID, Title: message.From.FirstName}, + Chat: Chat{ID: message.From.User.ID, Title: message.From.FirstName}, Text: message.Text, Timestamp: message.Timestamp, } From 6d19b33355e22d6395b22436bb9afc2848b22f1f Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Wed, 8 Apr 2020 22:38:31 +0300 Subject: [PATCH 4/9] blocked, pending users --- bot.go | 12 ++++++++++++ chat.go | 10 ++++++++++ client.go | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/bot.go b/bot.go index e879fb9..b359127 100644 --- a/bot.go +++ b/bot.go @@ -56,6 +56,18 @@ func (b *Bot) GetChatMembers(chatID string) ([]ChatMember, error) { return b.client.GetChatMembers(chatID) } +// GetChatBlockedUsers returns chat blocked users list: +// userID +func (b *Bot) GetChatBlockedUsers(chatID string) ([]User, error) { + return b.client.GetChatBlockedUsers(chatID) +} + +// GetChatPendingUsers returns chat join pending users list: +// userID +func (b *Bot) GetChatPendingUsers(chatID string) ([]User, error) { + return b.client.GetChatPendingUsers(chatID) +} + // GetFileInfo returns information about file: // id, type, size, filename, url func (b *Bot) GetFileInfo(fileID string) (*File, error) { diff --git a/chat.go b/chat.go index 3e441bd..ea3a21c 100644 --- a/chat.go +++ b/chat.go @@ -83,3 +83,13 @@ func (c *Chat) GetAdmins() ([]ChatMember, error) { func (c *Chat) GetMembers() ([]ChatMember, error) { return c.client.GetChatMembers(c.ID) } + +// Get chat blocked users list +func (c *Chat) GetBlockedUsers() ([]User, error) { + return c.client.GetChatBlockedUsers(c.ID) +} + +// Get chat join pending users list +func (c *Chat) GetPendingUsers() ([]User, error) { + return c.client.GetChatPendingUsers(c.ID) +} diff --git a/client.go b/client.go index 98a3519..c9fa54e 100644 --- a/client.go +++ b/client.go @@ -195,6 +195,40 @@ func (c *Client) GetChatMembers(chatID string) ([]ChatMember, error) { return members.List, nil } +func (c *Client) GetChatBlockedUsers(chatID string) ([]User, error) { + params := url.Values{ + "chatId": {chatID}, + } + + response, err := c.Do("/chats/getBlockedUsers", params, nil) + if err != nil { + return nil, fmt.Errorf("error while receiving blocked users: %s", err) + } + + users := new(UsersListResponse) + if err := json.Unmarshal(response, users); err != nil { + return nil, fmt.Errorf("error while unmarshalling blocked users: %s", err) + } + return users.List, nil +} + +func (c *Client) GetChatPendingUsers(chatID string) ([]User, error) { + params := url.Values{ + "chatId": {chatID}, + } + + response, err := c.Do("/chats/getPendingUsers", params, nil) + if err != nil { + return nil, fmt.Errorf("error while receiving pending users: %s", err) + } + + users := new(UsersListResponse) + if err := json.Unmarshal(response, users); err != nil { + return nil, fmt.Errorf("error while unmarshalling pending users: %s", err) + } + return users.List, nil +} + func (c *Client) GetFileInfo(fileID string) (*File, error) { params := url.Values{ "fileId": {fileID}, From 1dffc716b382750dfb3348e90f0cfb45d033c5b6 Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Wed, 8 Apr 2020 23:26:08 +0300 Subject: [PATCH 5/9] block/unblock users (+cursor todo) --- bot.go | 11 +++++++++++ chat.go | 11 +++++++++++ client.go | 37 +++++++++++++++++++++++++++++++++++++ client_test.go | 14 +++++++------- types.go | 1 + 5 files changed, 67 insertions(+), 7 deletions(-) diff --git a/bot.go b/bot.go index b359127..9f7d957 100644 --- a/bot.go +++ b/bot.go @@ -68,6 +68,17 @@ func (b *Bot) GetChatPendingUsers(chatID string) ([]User, error) { return b.client.GetChatPendingUsers(chatID) } +// BlockChatUser blocks user and removes him from chat. +// If deleteLastMessages is true, the messages written recently will be deleted +func (b *Bot) BlockChatUser(chatID, userID string, deleteLastMessages bool) error { + return b.client.BlockChatUser(chatID, userID, deleteLastMessages) +} + +// UnblockChatUser unblocks user in chat +func (b *Bot) UnblockChatUser(chatID, userID string) error { + return b.client.UnblockChatUser(chatID, userID) +} + // GetFileInfo returns information about file: // id, type, size, filename, url func (b *Bot) GetFileInfo(fileID string) (*File, error) { diff --git a/chat.go b/chat.go index ea3a21c..c38204a 100644 --- a/chat.go +++ b/chat.go @@ -93,3 +93,14 @@ func (c *Chat) GetBlockedUsers() ([]User, error) { func (c *Chat) GetPendingUsers() ([]User, error) { return c.client.GetChatPendingUsers(c.ID) } + +// Block user and remove him from chat. +// If deleteLastMessages is true, the messages written recently will be deleted +func (c *Chat) BlockUser(userID string, deleteLastMessages bool) error { + return c.client.BlockChatUser(c.ID, userID, deleteLastMessages) +} + +// Unblock user in chat (but not add him back) +func (c *Chat) UnblockUser(userID string) error { + return c.client.UnblockChatUser(c.ID, userID) +} diff --git a/client.go b/client.go index c9fa54e..afc2827 100644 --- a/client.go +++ b/client.go @@ -229,6 +229,43 @@ func (c *Client) GetChatPendingUsers(chatID string) ([]User, error) { return users.List, nil } +func (c *Client) BlockChatUser(chatID, userID string, deleteLastMessages bool) error { + params := url.Values{ + "chatId": {chatID}, + "userId": {userID}, + "delLastMessages": {strconv.FormatBool(deleteLastMessages)}, + } + + response, err := c.Do("/chats/blockUser", params, nil) + if err != nil { + return fmt.Errorf("error while blocking user: %s", err) + } + + users := new(UsersListResponse) + if err := json.Unmarshal(response, users); err != nil { + return fmt.Errorf("error while blocking user: %s", err) + } + return nil +} + +func (c *Client) UnblockChatUser(chatID, userID string) error { + params := url.Values{ + "chatId": {chatID}, + "userId": {userID}, + } + + response, err := c.Do("/chats/unblockUser", params, nil) + if err != nil { + return fmt.Errorf("error while unblocking user: %s", err) + } + + users := new(UsersListResponse) + if err := json.Unmarshal(response, users); err != nil { + return fmt.Errorf("error while unblocking user: %s", err) + } + return nil +} + func (c *Client) GetFileInfo(fileID string) (*File, error) { params := url.Values{ "fileId": {fileID}, diff --git a/client_test.go b/client_test.go index 4340c5f..bee5e9e 100644 --- a/client_test.go +++ b/client_test.go @@ -67,7 +67,7 @@ func TestClient_GetEvents_OK(t *testing.T) { Title: "The best channel", }, From: Contact{ - UserID: "1234567890", + User: User{"1234567890"}, FirstName: "Name", LastName: "SurName", }, @@ -134,7 +134,7 @@ func TestClient_GetEvents_OK(t *testing.T) { Title: "The best channel", }, From: Contact{ - UserID: "1234567890", + User: User{"1234567890"}, FirstName: "Name", LastName: "SurName", }, @@ -166,7 +166,7 @@ func TestClient_GetEvents_OK(t *testing.T) { Title: "The best group", }, From: Contact{ - UserID: "9876543210", + User: User{"9876543210"}, FirstName: "Name", LastName: "SurName", }, @@ -198,13 +198,13 @@ func TestClient_GetEvents_OK(t *testing.T) { }, NewMembers: []Contact{ { - UserID: "1234567890", + User: User{"1234567890"}, FirstName: "Name", LastName: "SurName", }, }, AddedBy: Contact{ - UserID: "9876543210", + User: User{"9876543210"}, FirstName: "Name", LastName: "SurName", }, @@ -221,13 +221,13 @@ func TestClient_GetEvents_OK(t *testing.T) { }, LeftMembers: []Contact{ { - UserID: "1234567890", + User: User{"1234567890"}, FirstName: "Name", LastName: "SurName", }, }, RemovedBy: Contact{ - UserID: "9876543210", + User: User{"9876543210"}, FirstName: "Name", LastName: "SurName", }, diff --git a/types.go b/types.go index ea72975..4042bb5 100644 --- a/types.go +++ b/types.go @@ -68,6 +68,7 @@ type UsersListResponse struct { } type MembersListResponse struct { + // TODO: cursor List []ChatMember `json:"members"` } From dbd8338181cc177658541fc8d0863bcee060a31a Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Thu, 16 Apr 2020 19:53:22 +0300 Subject: [PATCH 6/9] resolve pending, set title, about, rules --- bot.go | 20 ++++++++++++++++++ chat.go | 31 +++++++++++++++++++++++++--- chat_easyjson.go | 12 +++++------ client.go | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 9 deletions(-) diff --git a/bot.go b/bot.go index 9f7d957..728563b 100644 --- a/bot.go +++ b/bot.go @@ -79,6 +79,26 @@ func (b *Bot) UnblockChatUser(chatID, userID string) error { return b.client.UnblockChatUser(chatID, userID) } +// ResolveChatJoinRequests sends a decision to accept/decline user join to chat +func (b *Bot) ResolveChatJoinRequests(chatID, userID string, accept, everyone bool) error { + return b.client.ResolveChatPending(chatID, userID, accept, everyone) +} + +// SetChatTitle changes chat title +func (b *Bot) SetChatTitle(chatID, title string) error { + return b.client.SetChatTitle(chatID, title) +} + +// SetChatAbout changes chat about +func (b *Bot) SetChatAbout(chatID, about string) error { + return b.client.SetChatAbout(chatID, about) +} + +// SetChatRules changes chat rules +func (b *Bot) SetChatRules(chatID, rules string) error { + return b.client.SetChatRules(chatID, rules) +} + // GetFileInfo returns information about file: // id, type, size, filename, url func (b *Bot) GetFileInfo(fileID string) (*File, error) { diff --git a/chat.go b/chat.go index c38204a..f09ac48 100644 --- a/chat.go +++ b/chat.go @@ -40,12 +40,12 @@ type Chat struct { // Rules of the group/channel Rules string `json:"rules"` - // Flag that indicates that requested chat is the bot - IsBot bool `json:"isBot"` - // Title of the chat Title string `json:"title"` + // Flag that indicates that requested chat is the bot + IsBot bool `json:"isBot"` + // Is this chat public? Public bool `json:"public"` @@ -104,3 +104,28 @@ func (c *Chat) BlockUser(userID string, deleteLastMessages bool) error { func (c *Chat) UnblockUser(userID string) error { return c.client.UnblockChatUser(c.ID, userID) } + +// ResolveJoinRequest resolve specific user chat join request +func (c *Chat) ResolveJoinRequest(userID string, accept bool) error { + return c.client.ResolveChatPending(c.ID, userID, accept, false) +} + +// ResolveAllJoinRequest resolve all chat join requests +func (c *Chat) ResolveAllJoinRequests(accept bool) error { + return c.client.ResolveChatPending(c.ID, "", accept, true) +} + +// SetTitle changes chat title +func (c *Chat) SetTitle(title string) error { + return c.client.SetChatTitle(c.ID, title) +} + +// SetAbout changes chat about +func (c *Chat) SetAbout(about string) error { + return c.client.SetChatAbout(c.ID, about) +} + +// SetRules changes chat rules +func (c *Chat) SetRules(rules string) error { + return c.client.SetChatRules(c.ID, rules) +} diff --git a/chat_easyjson.go b/chat_easyjson.go index 44cbdb0..6d9a48f 100644 --- a/chat_easyjson.go +++ b/chat_easyjson.go @@ -50,10 +50,10 @@ func easyjson9b8f5552DecodeGithubComMailRuImBotGolang(in *jlexer.Lexer, out *Cha out.About = string(in.String()) case "rules": out.Rules = string(in.String()) - case "isBot": - out.IsBot = bool(in.Bool()) case "title": out.Title = string(in.String()) + case "isBot": + out.IsBot = bool(in.Bool()) case "public": out.Public = bool(in.Bool()) case "joinModeration": @@ -110,14 +110,14 @@ func easyjson9b8f5552EncodeGithubComMailRuImBotGolang(out *jwriter.Writer, in Ch out.String(string(in.Rules)) } { - const prefix string = ",\"isBot\":" + const prefix string = ",\"title\":" out.RawString(prefix) - out.Bool(bool(in.IsBot)) + out.String(string(in.Title)) } { - const prefix string = ",\"title\":" + const prefix string = ",\"isBot\":" out.RawString(prefix) - out.String(string(in.Title)) + out.Bool(bool(in.IsBot)) } { const prefix string = ",\"public\":" diff --git a/client.go b/client.go index afc2827..05ba282 100644 --- a/client.go +++ b/client.go @@ -266,6 +266,59 @@ func (c *Client) UnblockChatUser(chatID, userID string) error { return nil } +func (c *Client) ResolveChatPending(chatID, userID string, approve, everyone bool) error { + params := url.Values{ + "chatId": {chatID}, + "approve": {strconv.FormatBool(approve)}, + } + if everyone { + params.Set("everyone", "true") + } else { + params.Set("userId", userID) + } + + if _, err := c.Do("/chats/resolvePending", params, nil); err != nil { + return fmt.Errorf("error while resolving chat pendings: %s", err) + } + return nil +} + +func (c *Client) SetChatTitle(chatID, title string) error { + params := url.Values{ + "chatId": {chatID}, + "title": {title}, + } + + if _, err := c.Do("/chats/setTitle", params, nil); err != nil { + return fmt.Errorf("error while setting chat title: %s", err) + } + return nil +} + +func (c *Client) SetChatAbout(chatID, about string) error { + params := url.Values{ + "chatId": {chatID}, + "about": {about}, + } + + if _, err := c.Do("/chats/setAbout", params, nil); err != nil { + return fmt.Errorf("error while setting chat about: %s", err) + } + return nil +} + +func (c *Client) SetChatRules(chatID, rules string) error { + params := url.Values{ + "chatId": {chatID}, + "rules": {rules}, + } + + if _, err := c.Do("/chats/setRules", params, nil); err != nil { + return fmt.Errorf("error while setting chat rules: %s", err) + } + return nil +} + func (c *Client) GetFileInfo(fileID string) (*File, error) { params := url.Values{ "fileId": {fileID}, From c5243c62ab02040769cfd2f657a32c1b3ff22890 Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Thu, 16 Apr 2020 20:22:57 +0300 Subject: [PATCH 7/9] tests fix --- client_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client_test.go b/client_test.go index 614ee2f..3ce1280 100644 --- a/client_test.go +++ b/client_test.go @@ -239,7 +239,7 @@ func TestClient_GetEvents_OK(t *testing.T) { Payload: EventPayload{ CallbackData: "echo", From: Contact{ - UserID: "1234567890", + User: User{"1234567890"}, FirstName: "Name", }, QueryID: "SVR:123456", From fe053b2c71a8676329ed7b91e34695599c89c308 Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Fri, 17 Apr 2020 01:11:41 +0300 Subject: [PATCH 8/9] go.dev badge, API specification links --- README.md | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ed76518..a271286 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ -# Golang interface for bot API +# Golang interface for Mail.ru Instant Messengers bot API [![CircleCI](https://circleci.com/gh/mail-ru-im/bot-golang.svg?style=svg)](https://circleci.com/gh/mail-ru-im/bot-golang) +[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/mail-ru-im/bot-golang) - *Brand new Bot API!* @@ -9,6 +10,12 @@ - *Simple and clear interface* +## API specification: +### [ ICQ New ](https://icq.com/botapi/) +### [ Myteam ](https://myteam.mail.ru/botapi/) + +### [ Agent Mail.ru](https://agent.mail.ru/botapi/) + ## Install ```bash go get github.com/mail-ru-im/bot-golang @@ -82,27 +89,3 @@ And debug all api requests and responses: ```go bot := botgolang.NewBot(BOT_TOKEN, botgolang.BotDebug(true)) ``` - - -## Roadmap - -- [x] Send message - -- [x] Events subscription - -- [x] Tests - -- [x] Godoc - -- [x] Edit message - -- [x] Send files - -- [x] Delete message - -- [x] Chat info - -- [x] Send voice - -- [x] File info - From 2b5e3bdf265b49f4a84d0a56e8f62871acc1a2af Mon Sep 17 00:00:00 2001 From: George Gabolaev Date: Fri, 17 Apr 2020 01:16:29 +0300 Subject: [PATCH 9/9] License badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a271286..dc0bc01 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Golang interface for Mail.ru Instant Messengers bot API +![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg) [![CircleCI](https://circleci.com/gh/mail-ru-im/bot-golang.svg?style=svg)](https://circleci.com/gh/mail-ru-im/bot-golang) [![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/mail-ru-im/bot-golang)