-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwall.go
More file actions
608 lines (528 loc) · 18.8 KB
/
wall.go
File metadata and controls
608 lines (528 loc) · 18.8 KB
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
package vkapi
// ===================
// WallCloseComments
// ===================
// WallCloseCommentsParams параметры метода WallCloseComments.
type WallCloseCommentsParams struct {
OwnerID int
PostID uint
}
// WallCloseComments выключает комментирование записи.
func (api *API) WallCloseComments(p WallCloseCommentsParams) (bool, error) {
resp, err := api.Request("wall.closeComments", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// ===================
// WallCreateComment
// ===================
// WallCreateCommentParams параметры метода WallCreateComment.
type WallCreateCommentParams struct {
OwnerID int
PostID uint
FromGroup uint
Message string
ReplyToComment int
Attachments string
StickerID uint
GUID string
}
// WallCreateCommentResp структура, возвращаемая методом WallCreateComment.
type WallCreateCommentResp struct {
CommentID int `json:"comment_id"`
ParentsStack []int `json:"parents_stack"`
}
// WallCreateComment добавляет комментарий к записи на стене.
func (api *API) WallCreateComment(p WallCreateCommentParams) (*WallCreateCommentResp, error) {
resp, err := api.Request("wall.createComment", p, new(WallCreateCommentResp))
if err != nil {
return nil, err
}
return resp.(*WallCreateCommentResp), nil
}
// ============
// WallDelete
// ============
// WallDeleteParams параметры метода WallDelete.
type WallDeleteParams struct {
OwnerID int
PostID uint
}
// WallDelete удаляет запись со стены.
func (api *API) WallDelete(p WallDeleteParams) (bool, error) {
resp, err := api.Request("wall.delete", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// ===================
// WallDeleteComment
// ===================
// WallDeleteCommentParams параметры метода WallDeleteComment.
type WallDeleteCommentParams struct {
OwnerID int
CommentID uint
}
// WallDeleteComment удаляет комментарий к записи на стене.
func (api *API) WallDeleteComment(p WallDeleteCommentParams) (bool, error) {
resp, err := api.Request("wall.deleteComment", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// ==========
// WallEdit
// ==========
// WallEditParams параметры метода WallEdit.
type WallEditParams struct {
OwnerID int
PostID uint
FriendsOnly bool
Message string
Attachments string
Services string
Signed bool
PublishDate int64
Lat float32
Long float32
PlaceID uint
MarkAsAds bool
CloseComments bool
PosterBkgID uint
PosterBkgOwnerID int
PosterBkgAccessHash string
}
// WallEditResp структура, возвращаемая методом WallEdit.
type WallEditResp struct {
PostID int `json:"post_id"`
}
// WallEdit редактирует запись на стене.
func (api *API) WallEdit(p WallEditParams) (*WallEditResp, error) {
resp, err := api.Request("wall.edit", p, new(WallEditResp))
if err != nil {
return nil, err
}
return resp.(*WallEditResp), nil
}
// ====================
// WallEditAdsStealth
// ====================
// WallEditAdsStealthParams параметры метода WallEditAdsStealth.
type WallEditAdsStealthParams struct {
OwnerID int
PostID uint
Message string
Attachments string
Signed bool
Lat float32
Long float32
PlaceID uint
LinkButton string
LinkTitle string
LinkImage string
LinkVideo string
}
// WallEditAdsStealth позволяет отредактировать скрытую запись. Создание скрытых записей возможно только в сообществах от имени группы, публичной страницы или мероприятия; пользователь должен обладать правами администратора или редактора.
func (api *API) WallEditAdsStealth(p WallEditAdsStealthParams) (bool, error) {
resp, err := api.Request("wall.editAdsStealth", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// =================
// WallEditComment
// =================
// WallEditCommentParams параметры метода WallEditComment.
type WallEditCommentParams struct {
OwnerID int
CommentID uint
Message string
Attachments string
}
// WallEditComment редактирует комментарий на стене.
func (api *API) WallEditComment(p WallEditCommentParams) (bool, error) {
resp, err := api.Request("wall.editComment", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// =========
// WallGet
// =========
// WallGetParams параметры метода WallGet.
type WallGetParams struct {
OwnerID int
Domain string
Offset uint
Count uint
Filter string
Extended bool
Fields string
}
// WallGetResp структура, возвращаемая методом WallGet.
type WallGetResp struct {
Count int `json:"count"`
Items []Post `json:"items"`
Profiles []User `json:"profiles"`
Groups []Group `json:"groups"`
}
// WallGet возвращает список записей со стены пользователя или сообщества. Обратите внимание, для этого метода действуют специальные ограничения на число запросов. https://vk.com/dev/data_limits
func (api *API) WallGet(p WallGetParams) (*WallGetResp, error) {
resp, err := api.Request("wall.get", p, new(WallGetResp))
if err != nil {
return nil, err
}
return resp.(*WallGetResp), nil
}
// =============
// WallGetByID
// =============
// WallGetByIDParams параметры метода WallGetById.
type WallGetByIDParams struct {
Posts string
Extended bool
CopyHistoryDepth uint
Fields string
}
// WallGetByIDResp структура, возвращаемая методом WallGetById.
type WallGetByIDResp struct {
Items []Post `json:"items"`
Profiles []User `json:"profiles"`
Groups []Group `json:"groups"`
}
// WallGetByID возвращает список записей со стен пользователей или сообществ по их идентификаторам. Возвращает []Post, если Extended=false или *WallGetByIDResp, если Extended=true.
func (api *API) WallGetByID(p WallGetByIDParams) (interface{}, error) {
var holder interface{}
switch p.Extended {
case true:
holder = new(WallGetByIDResp)
default:
holder = new([]Post)
}
resp, err := api.Request("wall.getById", p, holder)
if err != nil {
return nil, err
}
return resp, nil
}
// ================
// WallGetComment
// ================
// WallGetCommentParams параметры метода WallGetComment.
type WallGetCommentParams struct {
OwnerID int
CommentID uint
Extended bool
Fields string
}
// WallGetCommentResp структура, возвращаемая методом WallGetComment.
type WallGetCommentResp struct {
Items []Comment `json:"items"`
Profiles []User `json:"profiles"`
Groups []Group `json:"groups"`
}
// WallGetComment получает информацию о комментарии на стене.
func (api *API) WallGetComment(p WallGetCommentParams) (*WallGetCommentResp, error) {
resp, err := api.Request("wall.getComment", p, new(WallGetCommentResp))
if err != nil {
return nil, err
}
return resp.(*WallGetCommentResp), nil
}
// =================
// WallGetComments
// =================
// WallGetCommentsParams параметры метода WallGetComments.
type WallGetCommentsParams struct {
OwnerID int
PostID uint
NeedLikes bool
StartCommentID uint
Offset int
Count uint
Sort string
PreviewLength uint
Extended bool
Fields string
CommentID uint
ThreadItemsCount uint
}
// WallGetCommentsResp структура, возвращаемая методом WallGetComments.
type WallGetCommentsResp struct {
Count int `json:"count"`
Items []Comment `json:"items"`
CurrentLevelCount int `json:"current_level_count"`
CanPost bool `json:"can_post"`
ShowReplyButton bool `json:"show_reply_button"`
GroupsCanPost bool `json:"groups_can_post"`
RealOffset int `json:"real_offset"`
Profiles []User `json:"profiles"`
Groups []Group `json:"groups"`
}
// WallGetComments возвращает список комментариев к записи на стене.
func (api *API) WallGetComments(p WallGetCommentsParams) (*WallGetCommentsResp, error) {
resp, err := api.Request("wall.getComments", p, new(WallGetCommentsResp))
if err != nil {
return nil, err
}
return resp.(*WallGetCommentsResp), nil
}
// ================
// WallGetReposts
// ================
// WallGetRepostsParams параметры метода WallGetReposts.
type WallGetRepostsParams struct {
OwnerID int
PostID uint
Offset uint
Count uint
}
// WallGetRepostsResp структура, возвращаемая методом WallGetReposts.
type WallGetRepostsResp struct {
Items []Post `json:"items"`
Profiles []User `json:"profiles"`
Groups []Group `json:"groups"`
}
// WallGetReposts позволяет получать список репостов заданной записи. Обратите внимание, получить список репостов можно только для записи, созданной текущим пользователем, или в сообществе, где текущий пользователь является администратором.
func (api *API) WallGetReposts(p WallGetRepostsParams) (*WallGetRepostsResp, error) {
resp, err := api.Request("wall.getReposts", p, new(WallGetRepostsResp))
if err != nil {
return nil, err
}
return resp.(*WallGetRepostsResp), nil
}
// ==================
// WallOpenComments
// ==================
// WallOpenCommentsParams параметры метода WallOpenComments.
type WallOpenCommentsParams struct {
OwnerID int
PostID uint
}
// WallOpenComments включает комментирование записи работает только с конкретными записями, комментирование которых было выключено с помощью wall.closecomments
func (api *API) WallOpenComments(p WallOpenCommentsParams) (bool, error) {
resp, err := api.Request("wall.openComments", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// =========
// WallPin
// =========
// WallPinParams параметры метода WallPin.
type WallPinParams struct {
OwnerID int
PostID uint
}
// WallPin закрепляет запись на стене (запись будет отображаться выше остальных).
func (api *API) WallPin(p WallPinParams) (bool, error) {
resp, err := api.Request("wall.pin", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// ==========
// WallPost
// ==========
// WallPostParams параметры метода WallPost.
type WallPostParams struct {
OwnerID int
FriendsOnly bool
FromGroup bool
Message string
Attachments string
Services string
Signed bool
PublishDate int64
Lat float32
Long float32
PlaceID uint
PostID uint
GUID string
MarkAsAds bool
CloseComments bool
MuteNotifications bool
}
// WallPostResp структура, возвращаемая методом WallPost.
type WallPostResp struct {
PostID int `json:"post_id"`
}
// WallPost позволяет создать запись на стене, предложить запись на стене публичной страницы, опубликовать существующую отложенную запись. Чтобы создать предложенную запись, необходимо передать в owner_id идентификатор публичной страницы, в которой текущий пользователь не является руководителем. Для публикации предложенных и отложенных записей используйте параметр post_id, значение для которого можно получить методом wall.get с filter=suggests и postponed соответственно.
func (api *API) WallPost(p WallPostParams) (*WallPostResp, error) {
resp, err := api.Request("wall.post", p, new(WallPostResp))
if err != nil {
return nil, err
}
return resp.(*WallPostResp), nil
}
// ====================
// WallPostAdsStealth
// ====================
// WallPostAdsStealthParams параметры метода WallPostAdsStealth.
type WallPostAdsStealthParams struct {
OwnerID int
Message string
Attachments string
Signed bool
Lat float32
Long float32
PlaceID uint
GUID string
LinkButton string
LinkTitle string
LinkImage string
LinkVideo string
}
// WallPostAdsStealth позволяет создать скрытую запись, которая не попадает на стену сообщества и в дальнейшем может быть использована для создания рекламного объявления типа "запись в сообществе". Cоздание скрытых записей возможно только в сообществах от имени группы, публичной страницы или мероприятия; пользователь должен обладать правами администратора или редактора. Обратите внимание — в сутки можно создать не более 100 скрытых записей.
func (api *API) WallPostAdsStealth(p WallPostAdsStealthParams) (int, error) {
resp, err := api.Request("wall.postAdsStealth", p, new(int))
if err != nil {
return 0, err
}
return resp.(int), nil
}
// ===================
// WallReportComment
// ===================
// WallReportCommentParams параметры метода WallReportComment.
type WallReportCommentParams struct {
OwnerID int
CommentID uint
Reason uint
}
// WallReportComment позволяет пожаловаться на комментарий к записи.
func (api *API) WallReportComment(p WallReportCommentParams) (bool, error) {
resp, err := api.Request("wall.reportComment", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// ================
// WallReportPost
// ================
// WallReportPostParams параметры метода WallReportPost.
type WallReportPostParams struct {
OwnerID int
PostID uint
Reason uint
}
// WallReportPost позволяет пожаловаться на запись.
func (api *API) WallReportPost(p WallReportPostParams) (bool, error) {
resp, err := api.Request("wall.reportPost", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// ============
// WallRepost
// ============
// WallRepostParams параметры метода WallRepost.
type WallRepostParams struct {
Object string
Message string
GroupID uint
MarkAsAds bool
MuteNotifications bool
}
// WallRepostResp структура, возвращаемая методом WallRepost.
type WallRepostResp struct {
Success int `json:"success"`
PostID int `json:"post_id"`
RepostsCount int `json:"reposts_count"`
LikesCount int `json:"likes_count"`
}
// WallRepost копирует объект на стену пользователя или сообщества.
func (api *API) WallRepost(p WallRepostParams) (*WallRepostResp, error) {
resp, err := api.Request("wall.repost", p, new(WallRepostResp))
if err != nil {
return nil, err
}
return resp.(*WallRepostResp), nil
}
// =============
// WallRestore
// =============
// WallRestoreParams параметры метода WallRestore.
type WallRestoreParams struct {
OwnerID int
PostID uint
}
// WallRestore восстанавливает удаленную запись на стене пользователя или сообщества.
func (api *API) WallRestore(p WallRestoreParams) (bool, error) {
resp, err := api.Request("wall.restore", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// ====================
// WallRestoreComment
// ====================
// WallRestoreCommentParams параметры метода WallRestoreComment.
type WallRestoreCommentParams struct {
OwnerID int
CommentID uint
}
// WallRestoreComment восстанавливает удаленный комментарий к записи на стене.
func (api *API) WallRestoreComment(p WallRestoreCommentParams) (bool, error) {
resp, err := api.Request("wall.restoreComment", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}
// ============
// WallSearch
// ============
// WallSearchParams параметры метода WallSearch.
type WallSearchParams struct {
OwnerID int
Domain string
Query string
OwnersOnly bool
Count uint
Offset uint
Extended bool
Fields string
}
// WallSearchResp структура, возвращаемая методом WallSearch.
type WallSearchResp struct {
Count int `json:"count"`
Items []Post `json:"items"`
Profiles []User `json:"profiles"`
Groups []Group `json:"groups"`
}
// WallSearch позволяет искать записи на стене в соответствии с заданными критериями. Обратите внимание, для этого метода действуют специальные ограничения на число запросов. https://vk.com/dev/data_limits
func (api *API) WallSearch(p WallSearchParams) (*WallSearchResp, error) {
resp, err := api.Request("wall.search", p, new(WallSearchResp))
if err != nil {
return nil, err
}
return resp.(*WallSearchResp), nil
}
// ===========
// WallUnpin
// ===========
// WallUnpinParams параметры метода WallUnpin.
type WallUnpinParams struct {
OwnerID int
PostID uint
}
// WallUnpin отменяет закрепление записи на стене.
func (api *API) WallUnpin(p WallUnpinParams) (bool, error) {
resp, err := api.Request("wall.unpin", p, new(int))
if err != nil {
return false, err
}
return toBool(resp.(int)), nil
}