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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
|
package api // import "github.com/SevereCloud/vksdk/v2/api"
import (
"github.com/SevereCloud/vksdk/v2/object"
)
// MessagesAddChatUser adds a new user to a chat.
//
// https://vk.com/dev/messages.addChatUser
func (vk *VK) MessagesAddChatUser(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.addChatUser", &response, params)
return
}
// MessagesAllowMessagesFromGroup allows sending messages from community to the current user.
//
// https://vk.com/dev/messages.allowMessagesFromGroup
func (vk *VK) MessagesAllowMessagesFromGroup(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.allowMessagesFromGroup", &response, params)
return
}
// MessagesCreateChat creates a chat with several participants.
//
// https://vk.com/dev/messages.createChat
func (vk *VK) MessagesCreateChat(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.createChat", &response, params)
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 Params) (response MessagesDeleteResponse, err error) {
err = vk.RequestUnmarshal("messages.delete", &response, params)
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 Params) (response MessagesDeleteChatPhotoResponse, err error) {
err = vk.RequestUnmarshal("messages.deleteChatPhoto", &response, params)
return
}
// MessagesDeleteConversationResponse struct.
type MessagesDeleteConversationResponse struct {
LastDeletedID int `json:"last_deleted_id"` // Id of the last message, that was deleted
}
// MessagesDeleteConversation deletes private messages in a conversation.
//
// https://vk.com/dev/messages.deleteConversation
func (vk *VK) MessagesDeleteConversation(params Params) (response MessagesDeleteConversationResponse, err error) {
err = vk.RequestUnmarshal("messages.deleteConversation", &response, params)
return
}
// MessagesDenyMessagesFromGroup denies sending message from community to the current user.
//
// https://vk.com/dev/messages.denyMessagesFromGroup
func (vk *VK) MessagesDenyMessagesFromGroup(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.denyMessagesFromGroup", &response, params)
return
}
// MessagesEdit edits the message.
//
// https://vk.com/dev/messages.edit
func (vk *VK) MessagesEdit(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.edit", &response, params)
return
}
// MessagesEditChat edits the title of a chat.
//
// https://vk.com/dev/messages.editChat
func (vk *VK) MessagesEditChat(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.editChat", &response, params)
return
}
// MessagesGetByConversationMessageIDResponse struct.
type MessagesGetByConversationMessageIDResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
object.ExtendedResponse
}
// MessagesGetByConversationMessageID messages.getByConversationMessageId.
//
// https://vk.com/dev/messages.getByConversationMessageId
func (vk *VK) MessagesGetByConversationMessageID(params Params) (
response MessagesGetByConversationMessageIDResponse,
err error,
) {
err = vk.RequestUnmarshal("messages.getByConversationMessageId", &response, params)
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 Params) (response MessagesGetByIDResponse, err error) {
err = vk.RequestUnmarshal("messages.getById", &response, params, Params{"extended": false})
return
}
// MessagesGetByIDExtendedResponse struct.
type MessagesGetByIDExtendedResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
object.ExtendedResponse
}
// MessagesGetByIDExtended returns messages by their IDs.
//
// extended=1
//
// https://vk.com/dev/messages.getById
func (vk *VK) MessagesGetByIDExtended(params Params) (response MessagesGetByIDExtendedResponse, err error) {
err = vk.RequestUnmarshal("messages.getById", &response, params, Params{"extended": true})
return
}
// MessagesGetChatResponse struct.
type MessagesGetChatResponse object.MessagesChat
// MessagesGetChat returns information about a chat.
//
// https://vk.com/dev/messages.getChat
func (vk *VK) MessagesGetChat(params Params) (response MessagesGetChatResponse, err error) {
err = vk.RequestUnmarshal("messages.getChat", &response, params)
return
}
// MessagesGetChatChatIDsResponse struct.
type MessagesGetChatChatIDsResponse []object.MessagesChat
// MessagesGetChatChatIDs returns information about a chat.
//
// https://vk.com/dev/messages.getChat
func (vk *VK) MessagesGetChatChatIDs(params Params) (response MessagesGetChatChatIDsResponse, err error) {
err = vk.RequestUnmarshal("messages.getChat", &response, params)
return
}
// MessagesGetChatPreviewResponse struct.
type MessagesGetChatPreviewResponse struct {
Preview object.MessagesChatPreview `json:"preview"`
object.ExtendedResponse
}
// MessagesGetChatPreview allows to receive chat preview by the invitation link.
//
// https://vk.com/dev/messages.getChatPreview
func (vk *VK) MessagesGetChatPreview(params Params) (response MessagesGetChatPreviewResponse, err error) {
err = vk.RequestUnmarshal("messages.getChatPreview", &response, params)
return
}
// MessagesGetConversationMembersResponse struct.
type MessagesGetConversationMembersResponse struct {
Items []struct {
MemberID int `json:"member_id"`
JoinDate int `json:"join_date"`
InvitedBy int `json:"invited_by"`
IsOwner object.BaseBoolInt `json:"is_owner,omitempty"`
IsAdmin object.BaseBoolInt `json:"is_admin,omitempty"`
CanKick object.BaseBoolInt `json:"can_kick,omitempty"`
} `json:"items"`
Count int `json:"count"`
ChatRestrictions struct {
OnlyAdminsInvite object.BaseBoolInt `json:"only_admins_invite"`
OnlyAdminsEditPin object.BaseBoolInt `json:"only_admins_edit_pin"`
OnlyAdminsEditInfo object.BaseBoolInt `json:"only_admins_edit_info"`
AdminsPromoteUsers object.BaseBoolInt `json:"admins_promote_users"`
} `json:"chat_restrictions"`
object.ExtendedResponse
}
// MessagesGetConversationMembers returns a list of IDs of users participating in a conversation.
//
// https://vk.com/dev/messages.getConversationMembers
func (vk *VK) MessagesGetConversationMembers(params Params) (
response MessagesGetConversationMembersResponse,
err error,
) {
err = vk.RequestUnmarshal("messages.getConversationMembers", &response, params)
return
}
// MessagesGetConversationsResponse struct.
type MessagesGetConversationsResponse struct {
Count int `json:"count"`
Items []object.MessagesConversationWithMessage `json:"items"`
UnreadCount int `json:"unread_count"`
object.ExtendedResponse
}
// MessagesGetConversations returns a list of conversations.
//
// https://vk.com/dev/messages.getConversations
func (vk *VK) MessagesGetConversations(params Params) (response MessagesGetConversationsResponse, err error) {
err = vk.RequestUnmarshal("messages.getConversations", &response, params)
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 Params) (response MessagesGetConversationsByIDResponse, err error) {
err = vk.RequestUnmarshal("messages.getConversationsById", &response, params, Params{"extended": false})
return
}
// MessagesGetConversationsByIDExtendedResponse struct.
type MessagesGetConversationsByIDExtendedResponse struct {
Count int `json:"count"`
Items []object.MessagesConversation `json:"items"`
object.ExtendedResponse
}
// MessagesGetConversationsByIDExtended returns conversations by their IDs.
//
// extended=1
//
// https://vk.com/dev/messages.getConversationsById
func (vk *VK) MessagesGetConversationsByIDExtended(params Params) (
response MessagesGetConversationsByIDExtendedResponse,
err error,
) {
err = vk.RequestUnmarshal("messages.getConversationsById", &response, params, Params{"extended": true})
return
}
// MessagesGetHistoryResponse struct.
type MessagesGetHistoryResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
// extended=1
object.ExtendedResponse
// extended=1
Conversations []object.MessagesConversation `json:"conversations,omitempty"`
// Deprecated: use .Conversations.InRead
InRead int `json:"in_read,omitempty"`
// Deprecated: use .Conversations.OutRead
OutRead int `json:"out_read,omitempty"`
}
// MessagesGetHistory returns message history for the specified user or group chat.
//
// https://vk.com/dev/messages.getHistory
func (vk *VK) MessagesGetHistory(params Params) (response MessagesGetHistoryResponse, err error) {
err = vk.RequestUnmarshal("messages.getHistory", &response, params)
return
}
// MessagesGetHistoryAttachmentsResponse struct.
type MessagesGetHistoryAttachmentsResponse struct {
Items []object.MessagesHistoryAttachment `json:"items"`
NextFrom string `json:"next_from"`
object.ExtendedResponse
}
// MessagesGetHistoryAttachments returns media files from the dialog or group chat.
//
// https://vk.com/dev/messages.getHistoryAttachments
func (vk *VK) MessagesGetHistoryAttachments(params Params) (response MessagesGetHistoryAttachmentsResponse, err error) {
err = vk.RequestUnmarshal("messages.getHistoryAttachments", &response, params)
return
}
// MessagesGetImportantMessagesResponse struct.
type MessagesGetImportantMessagesResponse struct {
Messages struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
} `json:"messages"`
Conversations []object.MessagesConversation `json:"conversations"`
object.ExtendedResponse
}
// MessagesGetImportantMessages messages.getImportantMessages.
//
// https://vk.com/dev/messages.getImportantMessages
func (vk *VK) MessagesGetImportantMessages(params Params) (response MessagesGetImportantMessagesResponse, err error) {
err = vk.RequestUnmarshal("messages.getImportantMessages", &response, params)
return
}
// MessagesGetIntentUsersResponse struct.
type MessagesGetIntentUsersResponse struct {
Count int `json:"count"`
Items []int `json:"items"`
Profiles []object.MessagesMessage `json:"profiles,omitempty"`
}
// MessagesGetIntentUsers method.
//
// https://vk.com/dev/messages.getIntentUsers
func (vk *VK) MessagesGetIntentUsers(params Params) (response MessagesGetIntentUsersResponse, err error) {
err = vk.RequestUnmarshal("messages.getIntentUsers", &response, params)
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 Params) (response MessagesGetInviteLinkResponse, err error) {
err = vk.RequestUnmarshal("messages.getInviteLink", &response, params)
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 Params) (response MessagesGetLastActivityResponse, err error) {
err = vk.RequestUnmarshal("messages.getLastActivity", &response, params)
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"`
FromPTS int `json:"from_pts"`
More object.BaseBoolInt `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 Params) (response MessagesGetLongPollHistoryResponse, err error) {
err = vk.RequestUnmarshal("messages.getLongPollHistory", &response, params)
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 Params) (response MessagesGetLongPollServerResponse, err error) {
err = vk.RequestUnmarshal("messages.getLongPollServer", &response, params)
return
}
// MessagesIsMessagesFromGroupAllowedResponse struct.
type MessagesIsMessagesFromGroupAllowedResponse struct {
IsAllowed object.BaseBoolInt `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 Params) (
response MessagesIsMessagesFromGroupAllowedResponse,
err error,
) {
err = vk.RequestUnmarshal("messages.isMessagesFromGroupAllowed", &response, params)
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 Params) (response MessagesJoinChatByInviteLinkResponse, err error) {
err = vk.RequestUnmarshal("messages.joinChatByInviteLink", &response, params)
return
}
// MessagesMarkAsAnsweredConversation messages.markAsAnsweredConversation.
//
// https://vk.com/dev/messages.markAsAnsweredConversation
func (vk *VK) MessagesMarkAsAnsweredConversation(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.markAsAnsweredConversation", &response, params)
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 Params) (response MessagesMarkAsImportantResponse, err error) {
err = vk.RequestUnmarshal("messages.markAsImportant", &response, params)
return
}
// MessagesMarkAsImportantConversation messages.markAsImportantConversation.
//
// https://vk.com/dev/messages.markAsImportantConversation
func (vk *VK) MessagesMarkAsImportantConversation(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.markAsImportantConversation", &response, params)
return
}
// MessagesMarkAsRead marks messages as read.
//
// https://vk.com/dev/messages.markAsRead
func (vk *VK) MessagesMarkAsRead(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.markAsRead", &response, params)
return
}
// MessagesPinResponse struct.
type MessagesPinResponse object.MessagesMessage
// MessagesPin messages.pin.
//
// https://vk.com/dev/messages.pin
func (vk *VK) MessagesPin(params Params) (response MessagesPinResponse, err error) {
err = vk.RequestUnmarshal("messages.pin", &response, params)
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 Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.removeChatUser", &response, params)
return
}
// MessagesRestore restores a deleted message.
//
// https://vk.com/dev/messages.restore
func (vk *VK) MessagesRestore(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.restore", &response, params)
return
}
// MessagesSearchResponse struct.
type MessagesSearchResponse struct {
Count int `json:"count"`
Items []object.MessagesMessage `json:"items"`
object.ExtendedResponse
Conversations []object.MessagesConversation `json:"conversations,omitempty"`
}
// 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 Params) (response MessagesSearchResponse, err error) {
err = vk.RequestUnmarshal("messages.search", &response, params)
return
}
// MessagesSearchConversationsResponse struct.
type MessagesSearchConversationsResponse struct {
Count int `json:"count"`
Items []object.MessagesConversation `json:"items"`
object.ExtendedResponse
}
// MessagesSearchConversations returns a list of conversations that match search criteria.
//
// https://vk.com/dev/messages.searchConversations
func (vk *VK) MessagesSearchConversations(params Params) (response MessagesSearchConversationsResponse, err error) {
err = vk.RequestUnmarshal("messages.searchConversations", &response, params)
return
}
// MessagesSend sends a message.
//
// For user_ids or peer_ids parameters, use MessagesSendUserIDs.
//
// https://vk.com/dev/messages.send
func (vk *VK) MessagesSend(params Params) (response int, err error) {
reqParams := Params{
"user_ids": "",
"peer_ids": "",
}
err = vk.RequestUnmarshal("messages.send", &response, params, reqParams)
return
}
// MessagesSendUserIDsResponse struct.
//
// TODO: v3 rename MessagesSendPeerIDsResponse - user_ids outdated.
type MessagesSendUserIDsResponse []struct {
PeerID int `json:"peer_id"`
MessageID int `json:"message_id"`
ConversationMessageID int `json:"conversation_message_id"`
Error Error `json:"error"`
}
// MessagesSendPeerIDs sends a message.
//
// need peer_ids;
//
// https://vk.com/dev/messages.send
func (vk *VK) MessagesSendPeerIDs(params Params) (response MessagesSendUserIDsResponse, err error) {
err = vk.RequestUnmarshal("messages.send", &response, params)
return
}
// MessagesSendUserIDs sends a message.
//
// need user_ids or peer_ids;
//
// https://vk.com/dev/messages.send
//
// Deprecated: user_ids outdated, use MessagesSendPeerIDs.
func (vk *VK) MessagesSendUserIDs(params Params) (response MessagesSendUserIDsResponse, err error) {
return vk.MessagesSendPeerIDs(params)
}
// MessagesSendMessageEventAnswer method.
//
// https://vk.com/dev/messages.sendMessageEventAnswer
func (vk *VK) MessagesSendMessageEventAnswer(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.sendMessageEventAnswer", &response, params)
return
}
// MessagesSendSticker sends a message.
//
// https://vk.com/dev/messages.sendSticker
func (vk *VK) MessagesSendSticker(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.sendSticker", &response, params, Params{"user_ids": ""})
return
}
// MessagesSetActivity changes the status of a user as typing in a conversation.
//
// https://vk.com/dev/messages.setActivity
func (vk *VK) MessagesSetActivity(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.setActivity", &response, params)
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 Params) (response MessagesSetChatPhotoResponse, err error) {
err = vk.RequestUnmarshal("messages.setChatPhoto", &response, params)
return
}
// MessagesUnpin messages.unpin.
//
// https://vk.com/dev/messages.unpin
func (vk *VK) MessagesUnpin(params Params) (response int, err error) {
err = vk.RequestUnmarshal("messages.unpin", &response, params)
return
}
|