diff --git a/README.md b/README.md index ed76518..dc0bc01 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -# Golang interface for bot API +# 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) - *Brand new Bot API!* @@ -9,6 +11,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 +90,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 - diff --git a/bot.go b/bot.go index 0a4cfe9..a5f2ce9 100644 --- a/bot.go +++ b/bot.go @@ -39,6 +39,66 @@ func (b *Bot) GetChatInfo(chatID string) (*Chat, error) { return b.client.GetChatInfo(chatID) } +// 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) +} + +// 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) +} + +// 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) +} + +// 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) { @@ -119,7 +179,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/button_easyjson.go b/button_easyjson.go index e0f5c7f..b0aa781 100644 --- a/button_easyjson.go +++ b/button_easyjson.go @@ -17,7 +17,7 @@ var ( _ easyjson.Marshaler ) -func easyjsonF248ab8DecodeBotGolang(in *jlexer.Lexer, out *ButtonResponse) { +func easyjsonF248ab8DecodeGithubComMailRuImBotGolang(in *jlexer.Lexer, out *ButtonResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -56,7 +56,7 @@ func easyjsonF248ab8DecodeBotGolang(in *jlexer.Lexer, out *ButtonResponse) { in.Consumed() } } -func easyjsonF248ab8EncodeBotGolang(out *jwriter.Writer, in ButtonResponse) { +func easyjsonF248ab8EncodeGithubComMailRuImBotGolang(out *jwriter.Writer, in ButtonResponse) { out.RawByte('{') first := true _ = first @@ -91,27 +91,27 @@ func easyjsonF248ab8EncodeBotGolang(out *jwriter.Writer, in ButtonResponse) { // MarshalJSON supports json.Marshaler interface func (v ButtonResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonF248ab8EncodeBotGolang(&w, v) + easyjsonF248ab8EncodeGithubComMailRuImBotGolang(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v ButtonResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonF248ab8EncodeBotGolang(w, v) + easyjsonF248ab8EncodeGithubComMailRuImBotGolang(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ButtonResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonF248ab8DecodeBotGolang(&r, v) + easyjsonF248ab8DecodeGithubComMailRuImBotGolang(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *ButtonResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonF248ab8DecodeBotGolang(l, v) + easyjsonF248ab8DecodeGithubComMailRuImBotGolang(l, v) } -func easyjsonF248ab8DecodeBotGolang1(in *jlexer.Lexer, out *Button) { +func easyjsonF248ab8DecodeGithubComMailRuImBotGolang1(in *jlexer.Lexer, out *Button) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -146,7 +146,7 @@ func easyjsonF248ab8DecodeBotGolang1(in *jlexer.Lexer, out *Button) { in.Consumed() } } -func easyjsonF248ab8EncodeBotGolang1(out *jwriter.Writer, in Button) { +func easyjsonF248ab8EncodeGithubComMailRuImBotGolang1(out *jwriter.Writer, in Button) { out.RawByte('{') first := true _ = first @@ -171,23 +171,23 @@ func easyjsonF248ab8EncodeBotGolang1(out *jwriter.Writer, in Button) { // MarshalJSON supports json.Marshaler interface func (v Button) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjsonF248ab8EncodeBotGolang1(&w, v) + easyjsonF248ab8EncodeGithubComMailRuImBotGolang1(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Button) MarshalEasyJSON(w *jwriter.Writer) { - easyjsonF248ab8EncodeBotGolang1(w, v) + easyjsonF248ab8EncodeGithubComMailRuImBotGolang1(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Button) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjsonF248ab8DecodeBotGolang1(&r, v) + easyjsonF248ab8DecodeGithubComMailRuImBotGolang1(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Button) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjsonF248ab8DecodeBotGolang1(l, v) + easyjsonF248ab8DecodeGithubComMailRuImBotGolang1(l, v) } diff --git a/chat.go b/chat.go index 8095b1f..f09ac48 100644 --- a/chat.go +++ b/chat.go @@ -2,24 +2,130 @@ package botgolang //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"` // 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"` - 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"` +} + +func (c *Chat) resolveID() string { + switch c.Type { + case Private: + return c.Nick + default: + return c.ID + } +} + +// 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) +} + +// 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) +} + +// 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) +} + +// 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) +} - Admins []Contact `json:"admins"` +// 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 f0d23d7..6d9a48f 100644 --- a/chat_easyjson.go +++ b/chat_easyjson.go @@ -40,37 +40,26 @@ 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 "title": out.Title = string(in.String()) + case "isBot": + out.IsBot = bool(in.Bool()) 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": - if in.IsNull() { - in.Skip() - out.Admins = nil - } else { - in.Delim('[') - if out.Admins == nil { - if !in.IsDelim(']') { - out.Admins = make([]Contact, 0, 1) - } else { - out.Admins = []Contact{} - } - } else { - out.Admins = (out.Admins)[:0] - } - for !in.IsDelim(']') { - var v1 Contact - (v1).UnmarshalEasyJSON(in) - out.Admins = append(out.Admins, v1) - in.WantComma() - } - in.Delim(']') - } default: in.SkipRecursive() } @@ -95,42 +84,56 @@ 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 = ",\"title\":" out.RawString(prefix) out.String(string(in.Title)) } + { + const prefix string = ",\"isBot\":" + out.RawString(prefix) + out.Bool(bool(in.IsBot)) + } { const prefix string = ",\"public\":" out.RawString(prefix) 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\":" 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 7fba6ad..b3efafd 100644 --- a/client.go +++ b/client.go @@ -127,25 +127,196 @@ 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 } + return chat, nil +} - response, err = c.Do("/chats/getAdmins", params, 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) 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) } - if err := json.Unmarshal(response, chat); err != nil { + 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 +} - return chat, 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) 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) 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) 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) { diff --git a/client_test.go b/client_test.go index 4dbf99a..3ce1280 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", }, @@ -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", diff --git a/message_easyjson.go b/message_easyjson.go index 2e471b3..1754da2 100644 --- a/message_easyjson.go +++ b/message_easyjson.go @@ -54,6 +54,50 @@ func easyjson4086215fDecodeGithubComMailRuImBotGolang(in *jlexer.Lexer, out *Mes out.ForwardChatID = string(in.String()) case "timestamp": out.Timestamp = int(in.Int()) + case "inlineKeyboardMarkup": + if in.IsNull() { + in.Skip() + out.InlineKeyboard = nil + } else { + in.Delim('[') + if out.InlineKeyboard == nil { + if !in.IsDelim(']') { + out.InlineKeyboard = make([][]Button, 0, 2) + } else { + out.InlineKeyboard = [][]Button{} + } + } else { + out.InlineKeyboard = (out.InlineKeyboard)[:0] + } + for !in.IsDelim(']') { + var v1 []Button + if in.IsNull() { + in.Skip() + v1 = nil + } else { + in.Delim('[') + if v1 == nil { + if !in.IsDelim(']') { + v1 = make([]Button, 0, 1) + } else { + v1 = []Button{} + } + } else { + v1 = (v1)[:0] + } + for !in.IsDelim(']') { + var v2 Button + (v2).UnmarshalEasyJSON(in) + v1 = append(v1, v2) + in.WantComma() + } + in.Delim(']') + } + out.InlineKeyboard = append(out.InlineKeyboard, v1) + in.WantComma() + } + in.Delim(']') + } default: in.SkipRecursive() } @@ -113,6 +157,33 @@ func easyjson4086215fEncodeGithubComMailRuImBotGolang(out *jwriter.Writer, in Me out.RawString(prefix) out.Int(int(in.Timestamp)) } + { + const prefix string = ",\"inlineKeyboardMarkup\":" + out.RawString(prefix) + if in.InlineKeyboard == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v3, v4 := range in.InlineKeyboard { + if v3 > 0 { + out.RawByte(',') + } + if v4 == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v5, v6 := range v4 { + if v5 > 0 { + out.RawByte(',') + } + (v6).MarshalEasyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte(']') + } + } out.RawByte('}') } diff --git a/types.go b/types.go index d4ef3a3..5003900 100644 --- a/types.go +++ b/types.go @@ -34,8 +34,7 @@ type Photo struct { } type BotInfo struct { - // Id of the bot - UserID string `json:"userId"` + User // Nickname of the bot Nick string `json:"nick"` @@ -55,8 +54,31 @@ type eventsResponse struct { Events []*Event `json:"events"` } +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 { + // TODO: cursor + 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 8c2bae5..3877e6d 100644 --- a/types_easyjson.go +++ b/types_easyjson.go @@ -17,7 +17,7 @@ var ( _ easyjson.Marshaler ) -func easyjson6601e8cdDecodeBotGolang(in *jlexer.Lexer, out *Part) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang(in *jlexer.Lexer, out *eventsResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -36,10 +36,39 @@ func easyjson6601e8cdDecodeBotGolang(in *jlexer.Lexer, out *Part) { continue } switch key { - case "type": - out.Type = PartType(in.String()) - case "payload": - (out.Payload).UnmarshalEasyJSON(in) + case "ok": + out.OK = bool(in.Bool()) + case "events": + if in.IsNull() { + in.Skip() + out.Events = nil + } else { + in.Delim('[') + if out.Events == nil { + if !in.IsDelim(']') { + out.Events = make([]*Event, 0, 8) + } else { + out.Events = []*Event{} + } + } else { + out.Events = (out.Events)[:0] + } + for !in.IsDelim(']') { + var v1 *Event + if in.IsNull() { + in.Skip() + v1 = nil + } else { + if v1 == nil { + v1 = new(Event) + } + (*v1).UnmarshalEasyJSON(in) + } + out.Events = append(out.Events, v1) + in.WantComma() + } + in.Delim(']') + } default: in.SkipRecursive() } @@ -50,47 +79,62 @@ func easyjson6601e8cdDecodeBotGolang(in *jlexer.Lexer, out *Part) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang(out *jwriter.Writer, in Part) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang(out *jwriter.Writer, in eventsResponse) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"type\":" + const prefix string = ",\"ok\":" out.RawString(prefix[1:]) - out.String(string(in.Type)) + out.Bool(bool(in.OK)) } { - const prefix string = ",\"payload\":" + const prefix string = ",\"events\":" out.RawString(prefix) - (in.Payload).MarshalEasyJSON(out) + if in.Events == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v2, v3 := range in.Events { + if v2 > 0 { + out.RawByte(',') + } + if v3 == nil { + out.RawString("null") + } else { + (*v3).MarshalEasyJSON(out) + } + } + out.RawByte(']') + } } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v Part) MarshalJSON() ([]byte, error) { +func (v eventsResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeBotGolang(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v Part) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang(w, v) +func (v eventsResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *Part) UnmarshalJSON(data []byte) error { +func (v *eventsResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Part) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang(l, v) +func (v *eventsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang(l, v) } -func easyjson6601e8cdDecodeBotGolang1(in *jlexer.Lexer, out *Event) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang1(in *jlexer.Lexer, out *UsersListResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -109,12 +153,29 @@ func easyjson6601e8cdDecodeBotGolang1(in *jlexer.Lexer, out *Event) { continue } switch key { - case "eventId": - out.EventID = int(in.Int()) - case "type": - out.Type = EventType(in.String()) - case "payload": - (out.Payload).UnmarshalEasyJSON(in) + 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() } @@ -125,52 +186,258 @@ func easyjson6601e8cdDecodeBotGolang1(in *jlexer.Lexer, out *Event) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang1(out *jwriter.Writer, in Event) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang1(out *jwriter.Writer, in UsersListResponse) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"eventId\":" + const prefix string = ",\"users\":" out.RawString(prefix[1:]) - out.Int(int(in.EventID)) + 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 = ",\"type\":" - out.RawString(prefix) - out.String(string(in.Type)) + 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 { + 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 "ok": + out.OK = bool(in.Bool()) + case "description": + out.Description = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() } +} +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(out *jwriter.Writer, in Response) { + out.RawByte('{') + first := true + _ = first { - const prefix string = ",\"payload\":" + const prefix string = ",\"ok\":" + out.RawString(prefix[1:]) + out.Bool(bool(in.OK)) + } + if in.Description != "" { + const prefix string = ",\"description\":" out.RawString(prefix) - (in.Payload).MarshalEasyJSON(out) + out.String(string(in.Description)) } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v Event) MarshalJSON() ([]byte, error) { +func (v Response) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeBotGolang1(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v Event) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang1(w, v) +func (v Response) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang3(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *Event) UnmarshalJSON(data []byte) error { +func (v *Response) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang1(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Event) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang1(l, v) +func (v *Response) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang3(l, v) +} +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(in *jlexer.Lexer, out *Photo) { + 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 "url": + out.URL = string(in.String()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } } -func easyjson6601e8cdDecodeBotGolang2(in *jlexer.Lexer, out *PartPayload) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(out *jwriter.Writer, in Photo) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"url\":" + out.RawString(prefix[1:]) + out.String(string(in.URL)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Photo) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Photo) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang4(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Photo) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Photo) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang4(l, v) +} +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(in *jlexer.Lexer, out *PartPayload) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -213,7 +480,7 @@ func easyjson6601e8cdDecodeBotGolang2(in *jlexer.Lexer, out *PartPayload) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang2(out *jwriter.Writer, in PartPayload) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(out *jwriter.Writer, in PartPayload) { out.RawByte('{') first := true _ = first @@ -258,27 +525,27 @@ func easyjson6601e8cdEncodeBotGolang2(out *jwriter.Writer, in PartPayload) { // MarshalJSON supports json.Marshaler interface func (v PartPayload) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeBotGolang2(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v PartPayload) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang2(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang5(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *PartPayload) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang2(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *PartPayload) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang2(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang5(l, v) } -func easyjson6601e8cdDecodeBotGolang3(in *jlexer.Lexer, out *PartMessage) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(in *jlexer.Lexer, out *PartMessage) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -315,7 +582,7 @@ func easyjson6601e8cdDecodeBotGolang3(in *jlexer.Lexer, out *PartMessage) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang3(out *jwriter.Writer, in PartMessage) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(out *jwriter.Writer, in PartMessage) { out.RawByte('{') first := true _ = first @@ -345,27 +612,198 @@ func easyjson6601e8cdEncodeBotGolang3(out *jwriter.Writer, in PartMessage) { // MarshalJSON supports json.Marshaler interface func (v PartMessage) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeBotGolang3(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v PartMessage) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang3(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang6(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *PartMessage) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang3(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *PartMessage) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang3(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang6(l, v) } -func easyjson6601e8cdDecodeBotGolang4(in *jlexer.Lexer, out *EventPayload) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(in *jlexer.Lexer, out *Part) { + 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 "type": + out.Type = PartType(in.String()) + case "payload": + (out.Payload).UnmarshalEasyJSON(in) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(out *jwriter.Writer, in Part) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"type\":" + out.RawString(prefix[1:]) + out.String(string(in.Type)) + } + { + const prefix string = ",\"payload\":" + out.RawString(prefix) + (in.Payload).MarshalEasyJSON(out) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Part) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v Part) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang7(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Part) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *Part) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang7(l, v) +} +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 { @@ -400,7 +838,7 @@ func easyjson6601e8cdDecodeBotGolang4(in *jlexer.Lexer, out *EventPayload) { in.Delim('[') if out.Parts == nil { if !in.IsDelim(']') { - out.Parts = make([]Part, 0, 0) + out.Parts = make([]Part, 0, 1) } else { out.Parts = []Part{} } @@ -408,15 +846,19 @@ func easyjson6601e8cdDecodeBotGolang4(in *jlexer.Lexer, out *EventPayload) { out.Parts = (out.Parts)[:0] } for !in.IsDelim(']') { - var v1 Part - (v1).UnmarshalEasyJSON(in) - out.Parts = append(out.Parts, v1) + var v10 Part + (v10).UnmarshalEasyJSON(in) + out.Parts = append(out.Parts, v10) in.WantComma() } in.Delim(']') } case "timestamp": out.Timestamp = int(in.Int()) + case "queryId": + out.QueryID = string(in.String()) + case "callbackData": + out.CallbackData = string(in.String()) case "leftMembers": if in.IsNull() { in.Skip() @@ -433,9 +875,9 @@ func easyjson6601e8cdDecodeBotGolang4(in *jlexer.Lexer, out *EventPayload) { out.LeftMembers = (out.LeftMembers)[:0] } for !in.IsDelim(']') { - var v2 Contact - (v2).UnmarshalEasyJSON(in) - out.LeftMembers = append(out.LeftMembers, v2) + var v11 Contact + (v11).UnmarshalEasyJSON(in) + out.LeftMembers = append(out.LeftMembers, v11) in.WantComma() } in.Delim(']') @@ -456,9 +898,9 @@ func easyjson6601e8cdDecodeBotGolang4(in *jlexer.Lexer, out *EventPayload) { out.NewMembers = (out.NewMembers)[:0] } for !in.IsDelim(']') { - var v3 Contact - (v3).UnmarshalEasyJSON(in) - out.NewMembers = append(out.NewMembers, v3) + var v12 Contact + (v12).UnmarshalEasyJSON(in) + out.NewMembers = append(out.NewMembers, v12) in.WantComma() } in.Delim(']') @@ -467,10 +909,6 @@ func easyjson6601e8cdDecodeBotGolang4(in *jlexer.Lexer, out *EventPayload) { (out.AddedBy).UnmarshalEasyJSON(in) case "removedBy": (out.RemovedBy).UnmarshalEasyJSON(in) - case "queryId": - out.QueryID = string(in.String()) - case "callbackData": - out.CallbackData = string(in.String()) default: in.SkipRecursive() } @@ -481,7 +919,7 @@ func easyjson6601e8cdDecodeBotGolang4(in *jlexer.Lexer, out *EventPayload) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang4(out *jwriter.Writer, in EventPayload) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(out *jwriter.Writer, in EventPayload) { out.RawByte('{') first := true _ = first @@ -512,11 +950,11 @@ func easyjson6601e8cdEncodeBotGolang4(out *jwriter.Writer, in EventPayload) { out.RawString("null") } else { out.RawByte('[') - for v4, v5 := range in.Parts { - if v4 > 0 { + for v13, v14 := range in.Parts { + if v13 > 0 { out.RawByte(',') } - (v5).MarshalEasyJSON(out) + (v14).MarshalEasyJSON(out) } out.RawByte(']') } @@ -526,6 +964,16 @@ func easyjson6601e8cdEncodeBotGolang4(out *jwriter.Writer, in EventPayload) { out.RawString(prefix) out.Int(int(in.Timestamp)) } + { + const prefix string = ",\"queryId\":" + out.RawString(prefix) + out.String(string(in.QueryID)) + } + { + const prefix string = ",\"callbackData\":" + out.RawString(prefix) + out.String(string(in.CallbackData)) + } { const prefix string = ",\"leftMembers\":" out.RawString(prefix) @@ -533,11 +981,11 @@ func easyjson6601e8cdEncodeBotGolang4(out *jwriter.Writer, in EventPayload) { out.RawString("null") } else { out.RawByte('[') - for v6, v7 := range in.LeftMembers { - if v6 > 0 { + for v15, v16 := range in.LeftMembers { + if v15 > 0 { out.RawByte(',') } - (v7).MarshalEasyJSON(out) + (v16).MarshalEasyJSON(out) } out.RawByte(']') } @@ -549,11 +997,11 @@ func easyjson6601e8cdEncodeBotGolang4(out *jwriter.Writer, in EventPayload) { out.RawString("null") } else { out.RawByte('[') - for v8, v9 := range in.NewMembers { - if v8 > 0 { + for v17, v18 := range in.NewMembers { + if v17 > 0 { out.RawByte(',') } - (v9).MarshalEasyJSON(out) + (v18).MarshalEasyJSON(out) } out.RawByte(']') } @@ -568,43 +1016,113 @@ func easyjson6601e8cdEncodeBotGolang4(out *jwriter.Writer, in EventPayload) { out.RawString(prefix) (in.RemovedBy).MarshalEasyJSON(out) } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v EventPayload) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v EventPayload) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang9(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *EventPayload) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *EventPayload) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang9(l, v) +} +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(in *jlexer.Lexer, out *Event) { + 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 "eventId": + out.EventID = int(in.Int()) + case "type": + out.Type = EventType(in.String()) + case "payload": + (out.Payload).UnmarshalEasyJSON(in) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(out *jwriter.Writer, in Event) { + out.RawByte('{') + first := true + _ = first { - const prefix string = ",\"queryId\":" + const prefix string = ",\"eventId\":" + out.RawString(prefix[1:]) + out.Int(int(in.EventID)) + } + { + const prefix string = ",\"type\":" out.RawString(prefix) - out.String(string(in.QueryID)) + out.String(string(in.Type)) } { - const prefix string = ",\"callbackData\":" + const prefix string = ",\"payload\":" out.RawString(prefix) - out.String(string(in.CallbackData)) + (in.Payload).MarshalEasyJSON(out) } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v EventPayload) MarshalJSON() ([]byte, error) { +func (v Event) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeBotGolang4(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v EventPayload) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang4(w, v) +func (v Event) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang10(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *EventPayload) UnmarshalJSON(data []byte) error { +func (v *Event) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang4(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *EventPayload) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang4(l, v) +func (v *Event) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang10(l, v) } -func easyjson6601e8cdDecodeBotGolang5(in *jlexer.Lexer, out *Contact) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang11(in *jlexer.Lexer, out *Contact) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -623,12 +1141,12 @@ func easyjson6601e8cdDecodeBotGolang5(in *jlexer.Lexer, out *Contact) { 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() } @@ -639,18 +1157,13 @@ func easyjson6601e8cdDecodeBotGolang5(in *jlexer.Lexer, out *Contact) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang5(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)) } { @@ -658,33 +1171,38 @@ func easyjson6601e8cdEncodeBotGolang5(out *jwriter.Writer, in Contact) { 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{} - easyjson6601e8cdEncodeBotGolang5(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang11(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Contact) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang5(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang11(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Contact) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang5(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang11(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Contact) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang5(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang11(l, v) } -func easyjson6601e8cdDecodeBotGolang6(in *jlexer.Lexer, out *eventsResponse) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang12(in *jlexer.Lexer, out *ChatMember) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -703,39 +1221,12 @@ func easyjson6601e8cdDecodeBotGolang6(in *jlexer.Lexer, out *eventsResponse) { continue } switch key { - case "ok": - out.OK = bool(in.Bool()) - case "events": - if in.IsNull() { - in.Skip() - out.Events = nil - } else { - in.Delim('[') - if out.Events == nil { - if !in.IsDelim(']') { - out.Events = make([]*Event, 0, 8) - } else { - out.Events = []*Event{} - } - } else { - out.Events = (out.Events)[:0] - } - for !in.IsDelim(']') { - var v10 *Event - if in.IsNull() { - in.Skip() - v10 = nil - } else { - if v10 == nil { - v10 = new(Event) - } - (*v10).UnmarshalEasyJSON(in) - } - out.Events = append(out.Events, v10) - in.WantComma() - } - in.Delim(']') - } + case "creator": + out.Creator = bool(in.Bool()) + case "admin": + out.Admin = bool(in.Bool()) + case "userId": + out.ID = string(in.String()) default: in.SkipRecursive() } @@ -746,62 +1237,52 @@ func easyjson6601e8cdDecodeBotGolang6(in *jlexer.Lexer, out *eventsResponse) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang6(out *jwriter.Writer, in eventsResponse) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang12(out *jwriter.Writer, in ChatMember) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"ok\":" + const prefix string = ",\"creator\":" out.RawString(prefix[1:]) - out.Bool(bool(in.OK)) + out.Bool(bool(in.Creator)) } { - const prefix string = ",\"events\":" + const prefix string = ",\"admin\":" out.RawString(prefix) - if in.Events == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { - out.RawString("null") - } else { - out.RawByte('[') - for v11, v12 := range in.Events { - if v11 > 0 { - out.RawByte(',') - } - if v12 == nil { - out.RawString("null") - } else { - (*v12).MarshalEasyJSON(out) - } - } - out.RawByte(']') - } + 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 eventsResponse) MarshalJSON() ([]byte, error) { +func (v ChatMember) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeBotGolang6(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang12(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v eventsResponse) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang6(w, v) +func (v ChatMember) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang12(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *eventsResponse) UnmarshalJSON(data []byte) error { +func (v *ChatMember) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang6(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang12(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *eventsResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang6(l, v) +func (v *ChatMember) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMailRuImBotGolang12(l, v) } -func easyjson6601e8cdDecodeBotGolang7(in *jlexer.Lexer, out *BotInfo) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang13(in *jlexer.Lexer, out *BotInfo) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -820,8 +1301,6 @@ func easyjson6601e8cdDecodeBotGolang7(in *jlexer.Lexer, out *BotInfo) { continue } switch key { - case "userId": - out.UserID = string(in.String()) case "nick": out.Nick = string(in.String()) case "firstName": @@ -844,13 +1323,15 @@ func easyjson6601e8cdDecodeBotGolang7(in *jlexer.Lexer, out *BotInfo) { 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() } @@ -861,18 +1342,13 @@ func easyjson6601e8cdDecodeBotGolang7(in *jlexer.Lexer, out *BotInfo) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang7(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)) } { @@ -892,42 +1368,47 @@ func easyjson6601e8cdEncodeBotGolang7(out *jwriter.Writer, in BotInfo) { 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{} - easyjson6601e8cdEncodeBotGolang7(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang13(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v BotInfo) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang7(w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang13(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *BotInfo) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang7(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang13(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *BotInfo) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang7(l, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang13(l, v) } -func easyjson6601e8cdDecodeBotGolang8(in *jlexer.Lexer, out *Photo) { +func easyjson6601e8cdDecodeGithubComMailRuImBotGolang14(in *jlexer.Lexer, out *AdminsListResponse) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -946,8 +1427,29 @@ func easyjson6601e8cdDecodeBotGolang8(in *jlexer.Lexer, out *Photo) { continue } switch key { - case "url": - out.URL = string(in.String()) + 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() } @@ -958,111 +1460,49 @@ func easyjson6601e8cdDecodeBotGolang8(in *jlexer.Lexer, out *Photo) { in.Consumed() } } -func easyjson6601e8cdEncodeBotGolang8(out *jwriter.Writer, in Photo) { +func easyjson6601e8cdEncodeGithubComMailRuImBotGolang14(out *jwriter.Writer, in AdminsListResponse) { out.RawByte('{') first := true _ = first { - const prefix string = ",\"url\":" + const prefix string = ",\"admins\":" out.RawString(prefix[1:]) - out.String(string(in.URL)) - } - out.RawByte('}') -} - -// MarshalJSON supports json.Marshaler interface -func (v Photo) MarshalJSON() ([]byte, error) { - w := jwriter.Writer{} - easyjson6601e8cdEncodeBotGolang8(&w, v) - return w.Buffer.BuildBytes(), w.Error -} - -// MarshalEasyJSON supports easyjson.Marshaler interface -func (v Photo) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang8(w, v) -} - -// UnmarshalJSON supports json.Unmarshaler interface -func (v *Photo) UnmarshalJSON(data []byte) error { - r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang8(&r, v) - return r.Error() -} - -// UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Photo) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang8(l, v) -} -func easyjson6601e8cdDecodeBotGolang9(in *jlexer.Lexer, out *Response) { - 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 "ok": - out.OK = bool(in.Bool()) - case "description": - out.Description = string(in.String()) - default: - in.SkipRecursive() + 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(']') } - in.WantComma() - } - in.Delim('}') - if isTopLevel { - in.Consumed() - } -} -func easyjson6601e8cdEncodeBotGolang9(out *jwriter.Writer, in Response) { - out.RawByte('{') - first := true - _ = first - { - const prefix string = ",\"ok\":" - out.RawString(prefix[1:]) - out.Bool(bool(in.OK)) - } - if in.Description != "" { - const prefix string = ",\"description\":" - out.RawString(prefix) - out.String(string(in.Description)) } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface -func (v Response) MarshalJSON() ([]byte, error) { +func (v AdminsListResponse) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeBotGolang9(&w, v) + easyjson6601e8cdEncodeGithubComMailRuImBotGolang14(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface -func (v Response) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeBotGolang9(w, v) +func (v AdminsListResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMailRuImBotGolang14(w, v) } // UnmarshalJSON supports json.Unmarshaler interface -func (v *Response) UnmarshalJSON(data []byte) error { +func (v *AdminsListResponse) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeBotGolang9(&r, v) + easyjson6601e8cdDecodeGithubComMailRuImBotGolang14(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface -func (v *Response) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeBotGolang9(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, }