-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
messages.go
555 lines (484 loc) · 20.2 KB
/
messages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
package api // import "github.com/SevereCloud/vksdk/5.92/api"
import (
"github.com/SevereCloud/vksdk/5.92/object"
)
// MessagesAddChatUser adds a new user to a chat.
//
// https://vk.com/dev/messages.addChatUser
func (vk *VK) MessagesAddChatUser(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.addChatUser", params, &response, &vkErr)
return
}
// MessagesAllowMessagesFromGroup allows sending messages from community to the current user.
//
// https://vk.com/dev/messages.allowMessagesFromGroup
func (vk *VK) MessagesAllowMessagesFromGroup(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.allowMessagesFromGroup", params, &response, &vkErr)
return
}
// MessagesCreateChat creates a chat with several participants.
//
// https://vk.com/dev/messages.createChat
func (vk *VK) MessagesCreateChat(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.createChat", params, &response, &vkErr)
return
}
// MessagesDeleteResponse struct
type MessagesDeleteResponse map[string]int
// MessagesDelete deletes one or more messages.
//
// https://vk.com/dev/messages.delete
func (vk *VK) MessagesDelete(params map[string]string) (response MessagesDeleteResponse, vkErr Error) {
vk.RequestUnmarshal("messages.delete", params, &response, &vkErr)
return
}
// MessagesDeleteChatPhotoResponse struct
type MessagesDeleteChatPhotoResponse struct {
MessageID int `json:"message_id"`
Chat object.MessagesChat `json:"chat"`
}
// MessagesDeleteChatPhoto deletes a chat's cover picture.
//
// https://vk.com/dev/messages.deleteChatPhoto
func (vk *VK) MessagesDeleteChatPhoto(params map[string]string) (response MessagesDeleteChatPhotoResponse, vkErr Error) {
vk.RequestUnmarshal("messages.deleteChatPhoto", params, &response, &vkErr)
return
}
// MessagesDeleteConversation deletes private messages in a conversation.
//
// https://vk.com/dev/messages.deleteConversation
func (vk *VK) MessagesDeleteConversation(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.deleteConversation", params, &response, &vkErr)
return
}
// MessagesDenyMessagesFromGroup denies sending message from community to the current user.
//
// https://vk.com/dev/messages.denyMessagesFromGroup
func (vk *VK) MessagesDenyMessagesFromGroup(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.denyMessagesFromGroup", params, &response, &vkErr)
return
}
// MessagesEdit edits the message.
//
// https://vk.com/dev/messages.edit
func (vk *VK) MessagesEdit(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.edit", params, &response, &vkErr)
return
}
// MessagesEditChat edits the title of a chat.
//
// https://vk.com/dev/messages.editChat
func (vk *VK) MessagesEditChat(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.editChat", params, &response, &vkErr)
return
}
// MessagesGetByConversationMessageIDResponse struct
type MessagesGetByConversationMessageIDResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
}
// MessagesGetByConversationMessageID messages.getByConversationMessageId
//
// https://vk.com/dev/messages.getByConversationMessageId
func (vk *VK) MessagesGetByConversationMessageID(params map[string]string) (response MessagesGetByConversationMessageIDResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getByConversationMessageId", params, &response, &vkErr)
return
}
// MessagesGetByIDResponse struct
type MessagesGetByIDResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
}
// MessagesGetByID returns messages by their IDs.
//
// extended=0
//
// https://vk.com/dev/messages.getById
func (vk *VK) MessagesGetByID(params map[string]string) (response MessagesGetByIDResponse, vkErr Error) {
params["extended"] = "0"
vk.RequestUnmarshal("messages.getById", params, &response, &vkErr)
return
}
// MessagesGetByIDExtendedResponse struct
type MessagesGetByIDExtendedResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
}
// MessagesGetByIDExtended returns messages by their IDs.
//
// extended=1
//
// https://vk.com/dev/messages.getById
func (vk *VK) MessagesGetByIDExtended(params map[string]string) (response MessagesGetByIDExtendedResponse, vkErr Error) {
params["extended"] = "1"
vk.RequestUnmarshal("messages.getById", params, &response, &vkErr)
return
}
// MessagesGetChatResponse struct
type MessagesGetChatResponse object.MessagesChat
// MessagesGetChat returns information about a chat.
//
// https://vk.com/dev/messages.getChat
func (vk *VK) MessagesGetChat(params map[string]string) (response MessagesGetChatResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getChat", params, &response, &vkErr)
return
}
// MessagesGetChatChatIDsResponse struct
type MessagesGetChatChatIDsResponse []object.MessagesChat
// MessagesGetChatChatIDs returns information about a chat.
//
// https://vk.com/dev/messages.getChat
func (vk *VK) MessagesGetChatChatIDs(params map[string]string) (response MessagesGetChatChatIDsResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getChat", params, &response, &vkErr)
return
}
// MessagesGetChatPreviewResponse struct
type MessagesGetChatPreviewResponse struct {
Preview object.MessagesChat `json:"preview"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
}
// MessagesGetChatPreview allows to receive chat preview by the invitation link.
//
// https://vk.com/dev/messages.getChatPreview
func (vk *VK) MessagesGetChatPreview(params map[string]string) (response MessagesGetChatPreviewResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getChatPreview", params, &response, &vkErr)
return
}
// MessagesGetConversationMembersResponse struct
type MessagesGetConversationMembersResponse struct {
Items []struct {
MemberID int `json:"member_id"`
JoinDate int `json:"join_date"`
InvitedBy int `json:"invited_by"`
IsOwner bool `json:"is_owner,omitempty"`
IsAdmin bool `json:"is_admin,omitempty"`
CanKick bool `json:"can_kick,omitempty"`
} `json:"items"`
Count int `json:"count"`
ChatRestrictions struct {
OnlyAdminsInvite bool `json:"only_admins_invite"`
OnlyAdminsEditPin bool `json:"only_admins_edit_pin"`
OnlyAdminsEditInfo bool `json:"only_admins_edit_info"`
AdminsPromoteUsers bool `json:"admins_promote_users"`
} `json:"chat_restrictions"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
}
// MessagesGetConversationMembers Returns a list of IDs of users participating in a conversation.
//
// https://vk.com/dev/messages.getConversationMembers
func (vk *VK) MessagesGetConversationMembers(params map[string]string) (response MessagesGetConversationMembersResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getConversationMembers", params, &response, &vkErr)
return
}
// MessagesGetConversationsResponse struct
type MessagesGetConversationsResponse struct {
Count int `json:"count"`
Items []object.MessagesConversationWithMessage `json:"items"`
UnreadCount int `json:"unread_count"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
//
}
// MessagesGetConversations returns a list of conversations.
//
// https://vk.com/dev/messages.getConversations
func (vk *VK) MessagesGetConversations(params map[string]string) (response MessagesGetConversationsResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getConversations", params, &response, &vkErr)
return
}
// MessagesGetConversationsByIDResponse struct
type MessagesGetConversationsByIDResponse struct {
Count int `json:"count"`
Items []object.MessagesConversation `json:"items"`
}
// MessagesGetConversationsByID returns conversations by their IDs.
//
// extended=0
//
// https://vk.com/dev/messages.getConversationsById
func (vk *VK) MessagesGetConversationsByID(params map[string]string) (response MessagesGetConversationsByIDResponse, vkErr Error) {
params["extended"] = "0"
vk.RequestUnmarshal("messages.getConversationsById", params, &response, &vkErr)
return
}
// MessagesGetConversationsByIDExtendedResponse struct
type MessagesGetConversationsByIDExtendedResponse struct {
Count int `json:"count"`
Items []object.MessagesConversation `json:"items"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
}
// MessagesGetConversationsByIDExtended returns conversations by their IDs.
//
// extended=1
//
// https://vk.com/dev/messages.getConversationsById
func (vk *VK) MessagesGetConversationsByIDExtended(params map[string]string) (response MessagesGetConversationsByIDExtendedResponse, vkErr Error) {
params["extended"] = "1"
vk.RequestUnmarshal("messages.getConversationsById", params, &response, &vkErr)
return
}
// MessagesGetHistoryResponse struct
type MessagesGetHistoryResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
InRead int `json:"in_read"`
OutRead int `json:"out_read"`
}
// MessagesGetHistory returns message history for the specified user or group chat.
//
// https://vk.com/dev/messages.getHistory
func (vk *VK) MessagesGetHistory(params map[string]string) (response MessagesGetHistoryResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getHistory", params, &response, &vkErr)
return
}
// MessagesGetHistoryAttachmentsResponse struct
type MessagesGetHistoryAttachmentsResponse struct {
Items []object.MessagesHistoryAttachment `json:"items"`
NextFrom string `json:"next_from"`
}
// MessagesGetHistoryAttachments returns media files from the dialog or group chat.
//
// https://vk.com/dev/messages.getHistoryAttachments
func (vk *VK) MessagesGetHistoryAttachments(params map[string]string) (response MessagesGetHistoryAttachmentsResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getHistoryAttachments", params, &response, &vkErr)
return
}
// MessagesGetImportantMessagesResponse struct
type MessagesGetImportantMessagesResponse struct {
Messages struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
} `json:"messages"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
Conversations []object.MessagesConversation `json:"conversations"`
}
// MessagesGetImportantMessages messages.getImportantMessages
//
// https://vk.com/dev/messages.getImportantMessages
func (vk *VK) MessagesGetImportantMessages(params map[string]string) (response MessagesGetImportantMessagesResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getImportantMessages", params, &response, &vkErr)
return
}
// MessagesGetInviteLinkResponse struct
type MessagesGetInviteLinkResponse struct {
Link string `json:"link"`
}
// MessagesGetInviteLink receives a link to invite a user to the chat.
//
// https://vk.com/dev/messages.getInviteLink
func (vk *VK) MessagesGetInviteLink(params map[string]string) (response MessagesGetInviteLinkResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getInviteLink", params, &response, &vkErr)
return
}
// MessagesGetLastActivityResponse struct
type MessagesGetLastActivityResponse object.MessagesLastActivity
// MessagesGetLastActivity returns a user's current status and date of last activity.
//
// https://vk.com/dev/messages.getLastActivity
func (vk *VK) MessagesGetLastActivity(params map[string]string) (response MessagesGetLastActivityResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getLastActivity", params, &response, &vkErr)
return
}
// MessagesGetLongPollHistoryResponse struct
type MessagesGetLongPollHistoryResponse struct {
History [][]int `json:"history"`
Groups []object.GroupsGroup `json:"groups"`
Messages struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
} `json:"messages"`
Profiles []object.UsersUser `json:"profiles"`
// Chats struct {} `json:"chats"`
NewPTS int `json:"new_pts"`
More bool `json:"chats"`
Conversations []object.MessagesConversation `json:"conversations"`
}
// MessagesGetLongPollHistory returns updates in user's private messages.
//
// https://vk.com/dev/messages.getLongPollHistory
func (vk *VK) MessagesGetLongPollHistory(params map[string]string) (response MessagesGetLongPollHistoryResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getLongPollHistory", params, &response, &vkErr)
return
}
// MessagesGetLongPollServerResponse struct
type MessagesGetLongPollServerResponse object.MessagesLongpollParams
// MessagesGetLongPollServer returns data required for connection to a Long Poll server.
//
// https://vk.com/dev/messages.getLongPollServer
func (vk *VK) MessagesGetLongPollServer(params map[string]string) (response MessagesGetLongPollServerResponse, vkErr Error) {
vk.RequestUnmarshal("messages.getLongPollServer", params, &response, &vkErr)
return
}
// MessagesIsMessagesFromGroupAllowedResponse struct
type MessagesIsMessagesFromGroupAllowedResponse struct {
IsAllowed int `json:"is_allowed"`
}
// MessagesIsMessagesFromGroupAllowed returns information whether
// sending messages from the community to current user is allowed.
//
// https://vk.com/dev/messages.isMessagesFromGroupAllowed
func (vk *VK) MessagesIsMessagesFromGroupAllowed(params map[string]string) (response MessagesIsMessagesFromGroupAllowedResponse, vkErr Error) {
vk.RequestUnmarshal("messages.isMessagesFromGroupAllowed", params, &response, &vkErr)
return
}
// MessagesJoinChatByInviteLinkResponse struct
type MessagesJoinChatByInviteLinkResponse struct {
ChatID int `json:"chat_id"`
}
// MessagesJoinChatByInviteLink allows to enter the chat by the invitation link.
//
// https://vk.com/dev/messages.joinChatByInviteLink
func (vk *VK) MessagesJoinChatByInviteLink(params map[string]string) (response MessagesJoinChatByInviteLinkResponse, vkErr Error) {
vk.RequestUnmarshal("messages.joinChatByInviteLink", params, &response, &vkErr)
return
}
// MessagesMarkAsAnsweredConversation messages.markAsAnsweredConversation
//
// https://vk.com/dev/messages.markAsAnsweredConversation
func (vk *VK) MessagesMarkAsAnsweredConversation(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.markAsAnsweredConversation", params, &response, &vkErr)
return
}
// MessagesMarkAsImportantResponse struct
type MessagesMarkAsImportantResponse []int
// MessagesMarkAsImportant marks and un marks messages as important (starred).
//
// https://vk.com/dev/messages.markAsImportant
func (vk *VK) MessagesMarkAsImportant(params map[string]string) (response MessagesMarkAsImportantResponse, vkErr Error) {
vk.RequestUnmarshal("messages.markAsImportant", params, &response, &vkErr)
return
}
// MessagesMarkAsImportantConversation messages.markAsImportantConversation
//
// https://vk.com/dev/messages.markAsImportantConversation
func (vk *VK) MessagesMarkAsImportantConversation(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.markAsImportantConversation", params, &response, &vkErr)
return
}
// MessagesMarkAsRead marks messages as read.
//
// https://vk.com/dev/messages.markAsRead
func (vk *VK) MessagesMarkAsRead(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.markAsRead", params, &response, &vkErr)
return
}
// MessagesPinResponse struct
type MessagesPinResponse object.MessagesMessage
// MessagesPin messages.pin
//
// https://vk.com/dev/messages.pin
func (vk *VK) MessagesPin(params map[string]string) (response MessagesPinResponse, vkErr Error) {
vk.RequestUnmarshal("messages.pin", params, &response, &vkErr)
return
}
// MessagesRemoveChatUser Allows the current user to leave a chat or, if the current user started the chat, allows the user to remove another user from the chat.
//
// https://vk.com/dev/messages.removeChatUser
func (vk *VK) MessagesRemoveChatUser(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.removeChatUser", params, &response, &vkErr)
return
}
// MessagesRestore restores a deleted message.
//
// https://vk.com/dev/messages.restore
func (vk *VK) MessagesRestore(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.restore", params, &response, &vkErr)
return
}
// MessagesSearchResponse struct
type MessagesSearchResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
Conversations []object.MessagesConversation `json:"conversations"`
}
// MessagesSearch Returns a list of the current user's private messages that match search criteria.
//
// https://vk.com/dev/messages.search
func (vk *VK) MessagesSearch(params map[string]string) (response MessagesSearchResponse, vkErr Error) {
vk.RequestUnmarshal("messages.search", params, &response, &vkErr)
return
}
// MessagesSearchConversationsResponse struct
type MessagesSearchConversationsResponse struct {
Count int `json:"count"`
Items []object.MessagesConversation `json:"items"`
Profiles []object.UsersUser `json:"profiles"`
Groups []object.GroupsGroup `json:"groups"`
}
// MessagesSearchConversations returns a list of conversations that match search criteria.
//
// https://vk.com/dev/messages.searchConversations
func (vk *VK) MessagesSearchConversations(params map[string]string) (response MessagesSearchConversationsResponse, vkErr Error) {
vk.RequestUnmarshal("messages.searchConversations", params, &response, &vkErr)
return
}
// MessagesSend Sends a message
//
// https://vk.com/dev/messages.send
func (vk *VK) MessagesSend(params map[string]string) (response int, vkErr Error) {
params["user_ids"] = ""
vk.RequestUnmarshal("messages.send", params, &response, &vkErr)
return
}
// MessagesSendUserIDsResponse struct
type MessagesSendUserIDsResponse []struct {
PeerID int `json:"peer_id"`
MessageID int `json:"message_id"`
Error struct {
Code int `json:"code"`
Description string `json:"description"`
} `json:"error"`
}
// MessagesSendUserIDs Sends a message
//
// need user_ids
//
// https://vk.com/dev/messages.send
func (vk *VK) MessagesSendUserIDs(params map[string]string) (response MessagesSendUserIDsResponse, vkErr Error) {
vk.RequestUnmarshal("messages.send", params, &response, &vkErr)
return
}
// MessagesSendSticker Sends a message
//
// https://vk.com/dev/messages.sendSticker
func (vk *VK) MessagesSendSticker(params map[string]string) (response int, vkErr Error) {
params["user_ids"] = ""
vk.RequestUnmarshal("messages.sendSticker", params, &response, &vkErr)
return
}
// MessagesSetActivity changes the status of a user as typing in a conversation.
//
// https://vk.com/dev/messages.setActivity
func (vk *VK) MessagesSetActivity(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.setActivity", params, &response, &vkErr)
return
}
// MessagesSetChatPhotoResponse struct
type MessagesSetChatPhotoResponse struct {
MessageID int `json:"message_id"`
Chat object.MessagesChat `json:"chat"`
}
// MessagesSetChatPhoto sets a previously-uploaded picture as the cover picture of a chat.
//
// https://vk.com/dev/messages.setChatPhoto
func (vk *VK) MessagesSetChatPhoto(params map[string]string) (response MessagesSetChatPhotoResponse, vkErr Error) {
vk.RequestUnmarshal("messages.setChatPhoto", params, &response, &vkErr)
return
}
// MessagesUnpin messages.unpin
//
// https://vk.com/dev/messages.unpin
func (vk *VK) MessagesUnpin(params map[string]string) (response int, vkErr Error) {
vk.RequestUnmarshal("messages.unpin", params, &response, &vkErr)
return
}