-
Notifications
You must be signed in to change notification settings - Fork 7
/
VK.GroupEvents.pas
1652 lines (1496 loc) · 60.6 KB
/
VK.GroupEvents.pas
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
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit VK.GroupEvents;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
REST.Client, System.JSON, VK.Types, System.Generics.Collections,
VK.LongPollServer, VK.API, VK.Entity.Media, VK.Entity.Audio, VK.Entity.Video,
VK.Entity.Message, VK.Entity.ClientInfo, VK.Entity.Photo,
VK.Entity.GroupSettings;
type
TLongPollEventProc = procedure(GroupId: Integer; EventObject: TJSONValue; const EventId: string) of object;
TLongPollEvents = TDictionary<string, TLongPollEventProc>;
TVkObjectInfo = record
Id: Integer;
OwnerId: Integer;
end;
TVkCommentInfo = record
Id: Integer;
OwnerId: Integer;
DeleterId: Integer;
ObjectId: Integer;
UserId: Integer;
end;
TVkGroupUserBlock = record
AdminId: integer;
UserId: integer;
UnblockDate: TDateTime;
Reason: TVkUserBlockReason;
Comment: string;
end;
TVkGroupUserUnBlock = record
AdminId: integer;
UserId: integer;
ByEndDate: Boolean;
end;
TVkGroupPollVoteNew = record
OwnerId: integer;
PollId: integer;
OptionId: integer;
UserId: integer;
end;
TVkGroupOfficersEdit = record
AdminId: integer;
UserId: integer;
LevelOld: TVkGroupLevel;
LevelNew: TVkGroupLevel;
end;
TVkGroupChangePhoto = class
public
UserId: integer;
Photo: TVkPhoto;
destructor Destroy; override;
end;
TVkPayTransaction = record
FromId: Integer;
Amount: string;
Description: string;
Date: TDateTime;
end;
TVkAppPayload = record
UserId: Integer;
AppId: Integer;
Payload: string;
GroupId: Integer;
end;
TOnCommentAction = procedure(Sender: TObject; GroupId: Integer; Comment: TVkComment; Info: TVkObjectInfo; const EventId: string) of object;
TOnCommentDelete = procedure(Sender: TObject; GroupId: Integer; Info: TVkCommentInfo; const EventId: string) of object;
TOnGroupPollVoteNew = procedure(Sender: TObject; GroupId: Integer; Info: TVkGroupPollVoteNew; const EventId: string) of object;
TOnGroupLeave = procedure(Sender: TObject; GroupId: Integer; UserId: Integer; IsSelf: Boolean; const EventId: string) of object;
TOnGroupOfficersEdit = procedure(Sender: TObject; GroupId: Integer; Info: TVkGroupOfficersEdit; const EventId: string) of object;
TOnGroupJoin = procedure(Sender: TObject; GroupId: Integer; UserId: Integer; JoinType: TVkGroupJoinType; const EventId: string) of object;
TOnGroupUserBlock = procedure(Sender: TObject; GroupId: Integer; Info: TVkGroupUserBlock; const EventId: string) of object;
TOnGroupUserUnBlock = procedure(Sender: TObject; GroupId: Integer; Info: TVkGroupUserUnBlock; const EventId: string) of object;
TOnGroupChangeSettings = procedure(Sender: TObject; GroupId: Integer; Changes: TVkGroupSettingsChange; const EventId: string) of object;
TOnGroupPayTransaction = procedure(Sender: TObject; GroupId: Integer; Info: TVkPayTransaction; const EventId: string) of object;
TOnGroupAppPayload = procedure(Sender: TObject; GroupId: Integer; Info: TVkAppPayload; const EventId: string) of object;
TOnGroupChangePhoto = procedure(Sender: TObject; GroupId: Integer; Changes: TVkGroupChangePhoto; const EventId: string) of object;
TOnVideoNew = procedure(Sender: TObject; GroupId: Integer; Video: TVkVideo; const EventId: string) of object;
TOnPhotoNew = procedure(Sender: TObject; GroupId: Integer; Photo: TVkPhoto; const EventId: string) of object;
TOnWallPostAction = procedure(Sender: TObject; GroupId: Integer; Post: TVkPost; const EventId: string) of object;
TOnAudioNew = procedure(Sender: TObject; GroupId: Integer; Audio: TVkAudio; const EventId: string) of object;
TOnGroupMessageNew = procedure(Sender: TObject; GroupId: Integer; Message: TVkMessage; ClientInfo: TVkClientInfo; const EventId: string) of object;
TOnGroupMessageAction = procedure(Sender: TObject; GroupId: Integer; Message: TVkMessage; const EventId: string) of object;
TOnGroupMessageAccess = procedure(Sender: TObject; GroupId: Integer; UserId: Integer; Key: string; const EventId: string) of object;
TOnGroupMessageTypingState = procedure(Sender: TObject; GroupId: Integer; UserId: Integer; State: string; const EventId: string) of object;
TOnGroupUnhandledEvents = procedure(Sender: TObject; GroupId: Integer; JSON: TJSONValue) of object;
TCustomGroupEvents = class(TComponent)
private
FLongPollServer: TVkLongPollServer;
FVK: TCustomVK;
FGroupID: Integer;
FOnWallReplyNew: TOnCommentAction;
FOnWallReplyEdit: TOnCommentAction;
FOnWallReplyRestore: TOnCommentAction;
FOnWallReplyDelete: TOnCommentDelete;
FOnWallPostNew: TOnWallPostAction;
FOnWallRepost: TOnWallPostAction;
FOnAudioNew: TOnAudioNew;
FOnVideoNew: TOnVideoNew;
FOnMessageNew: TOnGroupMessageNew;
FOnMessageReply: TOnGroupMessageAction;
FOnMessageEdit: TOnGroupMessageAction;
FOnMessageAllow: TOnGroupMessageAccess;
FOnMessageDeny: TOnGroupMessageAccess;
FOnPhotoNew: TOnPhotoNew;
FOnVideoCommentDelete: TOnCommentDelete;
FOnVideoCommentEdit: TOnCommentAction;
FOnVideoCommentRestore: TOnCommentAction;
FOnVideoCommentNew: TOnCommentAction;
FOnPhotoCommentDelete: TOnCommentDelete;
FOnPhotoCommentEdit: TOnCommentAction;
FOnPhotoCommentRestore: TOnCommentAction;
FOnPhotoCommentNew: TOnCommentAction;
FOnBoardPostDelete: TOnCommentDelete;
FOnBoardPostEdit: TOnCommentAction;
FOnBoardPostRestore: TOnCommentAction;
FOnBoardPostNew: TOnCommentAction;
FOnMarketCommentRestore: TOnCommentAction;
FOnMarketCommentNew: TOnCommentAction;
FOnMarketCommentDelete: TOnCommentDelete;
FOnMarketCommentEdit: TOnCommentAction;
FOnGroupLeave: TOnGroupLeave;
FOnGroupJoin: TOnGroupJoin;
FOnUserBlock: TOnGroupUserBlock;
FOnUserUnBlock: TOnGroupUserUnBlock;
FOnGroupPollVoteNew: TOnGroupPollVoteNew;
FOnGroupOfficersEdit: TOnGroupOfficersEdit;
FOnGroupChangeSettings: TOnGroupChangeSettings;
FOnGroupChangePhoto: TOnGroupChangePhoto;
FOnGroupPayTransaction: TOnGroupPayTransaction;
FOnGroupAppPayload: TOnGroupAppPayload;
FOnMessageTypingState: TOnGroupMessageTypingState;
FVersion: string;
FLogging: Boolean;
FLongPollEvents: TLongPollEvents;
FOnGroupUnhandledEvents: TOnGroupUnhandledEvents;
procedure FOnError(Sender: TObject; E: Exception; Code: Integer; Text: string);
procedure FOnLongPollUpdate(Sender: TObject; GroupID: string; Update: TJSONValue);
procedure DoEvent(Sender: TObject; Update: TJSONValue);
procedure SetVK(const Value: TCustomVK);
procedure SetGroupID(const Value: Integer);
//
procedure DoAudioNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoBoardPostDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoBoardPostEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoBoardPostNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoBoardPostRestore(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoGroupJoin(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoGroupLeave(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoGroupOfficersEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMarketCommentDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMarketCommentEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMarketCommentNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMarketCommentRestore(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMessageAllow(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMessageDeny(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMessageTypingState(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMessageEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMessageNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoMessageReply(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoPhotoCommentDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoPhotoCommentEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoPhotoCommentNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoPhotoCommentRestore(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoPhotoNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoPollVoteNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoUserBlock(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoUserUnblock(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoVideoCommentEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoVideoCommentNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoVideoCommentRestore(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoVideoCommentDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoVideoNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoWallPostNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoWallReplyDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoWallReplyEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoWallReplyNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoWallReplyRestore(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoWallRepost(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoGroupChangeSettings(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoGroupChangePhoto(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoVkPayTransaction(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoAppPayload(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
procedure DoGroupUnhandledEvents(GroupId: Integer; JSON: TJSONValue);
//
procedure SetOnWallReplyNew(const Value: TOnCommentAction);
procedure SetOnWallReplyEdit(const Value: TOnCommentAction);
procedure SetOnWallReplyRestore(const Value: TOnCommentAction);
procedure SetOnWallReplyDelete(const Value: TOnCommentDelete);
procedure SetOnWallPostNew(const Value: TOnWallPostAction);
procedure SetOnWallRepost(const Value: TOnWallPostAction);
procedure SetOnAudioNew(const Value: TOnAudioNew);
procedure SetOnVideoNew(const Value: TOnVideoNew);
procedure SetOnMessageNew(const Value: TOnGroupMessageNew);
procedure SetOnMessageReply(const Value: TOnGroupMessageAction);
procedure SetOnMessageEdit(const Value: TOnGroupMessageAction);
procedure SetOnMessageAllow(const Value: TOnGroupMessageAccess);
procedure SetOnMessageDeny(const Value: TOnGroupMessageAccess);
procedure SetOnPhotoNew(const Value: TOnPhotoNew);
procedure SetOnVideoCommentDelete(const Value: TOnCommentDelete);
procedure SetOnVideoCommentEdit(const Value: TOnCommentAction);
procedure SetOnVideoCommentNew(const Value: TOnCommentAction);
procedure SetOnVideoCommentRestore(const Value: TOnCommentAction);
procedure SetOnPhotoCommentDelete(const Value: TOnCommentDelete);
procedure SetOnPhotoCommentEdit(const Value: TOnCommentAction);
procedure SetOnPhotoCommentNew(const Value: TOnCommentAction);
procedure SetOnPhotoCommentRestore(const Value: TOnCommentAction);
procedure SetOnBoardPostDelete(const Value: TOnCommentDelete);
procedure SetOnBoardPostEdit(const Value: TOnCommentAction);
procedure SetOnBoardPostNew(const Value: TOnCommentAction);
procedure SetOnBoardPostRestore(const Value: TOnCommentAction);
procedure SetOnMarketCommentDelete(const Value: TOnCommentDelete);
procedure SetOnMarketCommentEdit(const Value: TOnCommentAction);
procedure SetOnMarketCommentNew(const Value: TOnCommentAction);
procedure SetOnMarketCommentRestore(const Value: TOnCommentAction);
procedure SetOnGroupLeave(const Value: TOnGroupLeave);
procedure SetOnGroupJoin(const Value: TOnGroupJoin);
procedure SetOnUserBlock(const Value: TOnGroupUserBlock);
procedure SetOnUserUnBlock(const Value: TOnGroupUserUnBlock);
procedure SetOnGroupPollVoteNew(const Value: TOnGroupPollVoteNew);
procedure SetOnGroupOfficersEdit(const Value: TOnGroupOfficersEdit);
procedure SetOnGroupChangeSettings(const Value: TOnGroupChangeSettings);
procedure SetOnGroupChangePhoto(const Value: TOnGroupChangePhoto);
procedure SetOnGroupAppPayload(const Value: TOnGroupAppPayload);
procedure SetOnGroupPayTransaction(const Value: TOnGroupPayTransaction);
procedure SetOnMessageTypingState(const Value: TOnGroupMessageTypingState);
procedure SetOnGroupUnhandledEvents(const Value: TOnGroupUnhandledEvents);
function GetIsWork: Boolean;
procedure SetVersion(const Value: string);
procedure SetLogging(const Value: Boolean);
procedure SetAsync(const Value: Boolean);
function GetAsync: Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Stop;
function Start: Boolean;
procedure FillEvents;
property LongPollServer: TVkLongPollServer read FLongPollServer;
property VK: TCustomVK read FVK write SetVK;
property GroupID: Integer read FGroupID write SetGroupID;
property IsWork: Boolean read GetIsWork;
property Logging: Boolean read FLogging write SetLogging;
property Async: Boolean read GetAsync write SetAsync;
//
property OnWallReplyNew: TOnCommentAction read FOnWallReplyNew write SetOnWallReplyNew;
property OnWallReplyEdit: TOnCommentAction read FOnWallReplyEdit write SetOnWallReplyEdit;
property OnWallReplyRestore: TOnCommentAction read FOnWallReplyRestore write SetOnWallReplyRestore;
property OnWallReplyDelete: TOnCommentDelete read FOnWallReplyDelete write SetOnWallReplyDelete;
property OnWallPostNew: TOnWallPostAction read FOnWallPostNew write SetOnWallPostNew;
property OnWallRepost: TOnWallPostAction read FOnWallRepost write SetOnWallRepost;
property OnAudioNew: TOnAudioNew read FOnAudioNew write SetOnAudioNew;
property OnVideoNew: TOnVideoNew read FOnVideoNew write SetOnVideoNew;
property OnPhotoNew: TOnPhotoNew read FOnPhotoNew write SetOnPhotoNew;
property OnMessageNew: TOnGroupMessageNew read FOnMessageNew write SetOnMessageNew;
property OnMessageReply: TOnGroupMessageAction read FOnMessageReply write SetOnMessageReply;
property OnMessageEdit: TOnGroupMessageAction read FOnMessageEdit write SetOnMessageEdit;
property OnMessageAllow: TOnGroupMessageAccess read FOnMessageAllow write SetOnMessageAllow;
property OnMessageDeny: TOnGroupMessageAccess read FOnMessageDeny write SetOnMessageDeny;
property OnMessageTypingState: TOnGroupMessageTypingState read FOnMessageTypingState write SetOnMessageTypingState;
property OnVideoCommentNew: TOnCommentAction read FOnVideoCommentNew write SetOnVideoCommentNew;
property OnVideoCommentEdit: TOnCommentAction read FOnVideoCommentEdit write SetOnVideoCommentEdit;
property OnVideoCommentRestore: TOnCommentAction read FOnVideoCommentRestore write SetOnVideoCommentRestore;
property OnVideoCommentDelete: TOnCommentDelete read FOnVideoCommentDelete write SetOnVideoCommentDelete;
property OnPhotoCommentNew: TOnCommentAction read FOnPhotoCommentNew write SetOnPhotoCommentNew;
property OnPhotoCommentEdit: TOnCommentAction read FOnPhotoCommentEdit write SetOnPhotoCommentEdit;
property OnPhotoCommentRestore: TOnCommentAction read FOnPhotoCommentRestore write SetOnPhotoCommentRestore;
property OnPhotoCommentDelete: TOnCommentDelete read FOnPhotoCommentDelete write SetOnPhotoCommentDelete;
property OnBoardPostNew: TOnCommentAction read FOnBoardPostNew write SetOnBoardPostNew;
property OnBoardPostEdit: TOnCommentAction read FOnBoardPostEdit write SetOnBoardPostEdit;
property OnBoardPostRestore: TOnCommentAction read FOnBoardPostRestore write SetOnBoardPostRestore;
property OnBoardPostDelete: TOnCommentDelete read FOnBoardPostDelete write SetOnBoardPostDelete;
property OnMarketCommentNew: TOnCommentAction read FOnMarketCommentNew write SetOnMarketCommentNew;
property OnMarketCommentEdit: TOnCommentAction read FOnMarketCommentEdit write SetOnMarketCommentEdit;
property OnMarketCommentRestore: TOnCommentAction read FOnMarketCommentRestore write SetOnMarketCommentRestore;
property OnMarketCommentDelete: TOnCommentDelete read FOnMarketCommentDelete write SetOnMarketCommentDelete;
property OnGroupLeave: TOnGroupLeave read FOnGroupLeave write SetOnGroupLeave;
property OnGroupJoin: TOnGroupJoin read FOnGroupJoin write SetOnGroupJoin;
property OnUserBlock: TOnGroupUserBlock read FOnUserBlock write SetOnUserBlock;
property OnUserUnBlock: TOnGroupUserUnBlock read FOnUserUnBlock write SetOnUserUnBlock;
property OnGroupPollVoteNew: TOnGroupPollVoteNew read FOnGroupPollVoteNew write SetOnGroupPollVoteNew;
property OnGroupOfficersEdit: TOnGroupOfficersEdit read FOnGroupOfficersEdit write SetOnGroupOfficersEdit;
property OnGroupChangeSettings: TOnGroupChangeSettings read FOnGroupChangeSettings write SetOnGroupChangeSettings;
property OnGroupChangePhoto: TOnGroupChangePhoto read FOnGroupChangePhoto write SetOnGroupChangePhoto;
property OnGroupPayTransaction: TOnGroupPayTransaction read FOnGroupPayTransaction write SetOnGroupPayTransaction;
property OnGroupAppPayload: TOnGroupAppPayload read FOnGroupAppPayload write SetOnGroupAppPayload;
property OnGroupUnhandledEvents: TOnGroupUnhandledEvents read FOnGroupUnhandledEvents write SetOnGroupUnhandledEvents;
property Version: string read FVersion write SetVersion;
end;
TGroupEventsItems = TList<TCustomGroupEvents>;
TCustomGroupEventControl = class(TComponent)
private
FReaded: Boolean;
FItems: TGroupEventsItems;
FGroups: TStrings;
FVK: TCustomVK;
FOnWallReplyNew: TOnCommentAction;
FOnWallReplyEdit: TOnCommentAction;
FOnWallReplyRestore: TOnCommentAction;
FOnWallReplyDelete: TOnCommentDelete;
FOnWallPostNew: TOnWallPostAction;
FOnWallRepost: TOnWallPostAction;
FOnAudioNew: TOnAudioNew;
FOnVideoNew: TOnVideoNew;
FOnMessageNew: TOnGroupMessageNew;
FOnMessageReply: TOnGroupMessageAction;
FOnMessageEdit: TOnGroupMessageAction;
FOnMessageAllow: TOnGroupMessageAccess;
FOnMessageDeny: TOnGroupMessageAccess;
FOnPhotoNew: TOnPhotoNew;
FOnVideoCommentDelete: TOnCommentDelete;
FOnVideoCommentEdit: TOnCommentAction;
FOnVideoCommentRestore: TOnCommentAction;
FOnVideoCommentNew: TOnCommentAction;
FOnPhotoCommentDelete: TOnCommentDelete;
FOnPhotoCommentEdit: TOnCommentAction;
FOnPhotoCommentRestore: TOnCommentAction;
FOnPhotoCommentNew: TOnCommentAction;
FOnBoardPostDelete: TOnCommentDelete;
FOnBoardPostEdit: TOnCommentAction;
FOnBoardPostRestore: TOnCommentAction;
FOnBoardPostNew: TOnCommentAction;
FOnMarketCommentRestore: TOnCommentAction;
FOnMarketCommentNew: TOnCommentAction;
FOnMarketCommentDelete: TOnCommentDelete;
FOnMarketCommentEdit: TOnCommentAction;
FOnGroupLeave: TOnGroupLeave;
FOnGroupJoin: TOnGroupJoin;
FOnUserBlock: TOnGroupUserBlock;
FOnUserUnBlock: TOnGroupUserUnBlock;
FOnGroupPollVoteNew: TOnGroupPollVoteNew;
FOnGroupOfficersEdit: TOnGroupOfficersEdit;
FOnGroupChangeSettings: TOnGroupChangeSettings;
FOnGroupChangePhoto: TOnGroupChangePhoto;
FOnGroupPayTransaction: TOnGroupPayTransaction;
FOnGroupAppPayload: TOnGroupAppPayload;
FOnMessageTypingState: TOnGroupMessageTypingState;
FOnGroupUnhandledEvents: TOnGroupUnhandledEvents;
FVersion: string;
FLogging: Boolean;
procedure SetItems(const Value: TGroupEventsItems);
procedure SetGroups(const Value: TStrings);
procedure SetVK(const Value: TCustomVK);
procedure SetVersion(const Value: string);
procedure SetLogging(const Value: Boolean);
public
constructor Create(AOwner: TComponent); override;
procedure DefineProperties(Filer: TFiler); override;
destructor Destroy; override;
procedure Stop;
function Start: Boolean;
procedure FillFromList;
function Add(GroupId: Integer): TCustomGroupEvents;
property Items: TGroupEventsItems read FItems write SetItems;
property VK: TCustomVK read FVK write SetVK;
property Groups: TStrings read FGroups write SetGroups;
property Logging: Boolean read FLogging write SetLogging;
property OnWallReplyNew: TOnCommentAction read FOnWallReplyNew write FOnWallReplyNew;
property OnWallReplyEdit: TOnCommentAction read FOnWallReplyEdit write FOnWallReplyEdit;
property OnWallReplyRestore: TOnCommentAction read FOnWallReplyRestore write FOnWallReplyRestore;
property OnWallReplyDelete: TOnCommentDelete read FOnWallReplyDelete write FOnWallReplyDelete;
property OnWallPostNew: TOnWallPostAction read FOnWallPostNew write FOnWallPostNew;
property OnWallRepost: TOnWallPostAction read FOnWallRepost write FOnWallRepost;
property OnAudioNew: TOnAudioNew read FOnAudioNew write FOnAudioNew;
property OnVideoNew: TOnVideoNew read FOnVideoNew write FOnVideoNew;
property OnPhotoNew: TOnPhotoNew read FOnPhotoNew write FOnPhotoNew;
property OnMessageNew: TOnGroupMessageNew read FOnMessageNew write FOnMessageNew;
property OnMessageReply: TOnGroupMessageAction read FOnMessageReply write FOnMessageReply;
property OnMessageEdit: TOnGroupMessageAction read FOnMessageEdit write FOnMessageEdit;
property OnMessageAllow: TOnGroupMessageAccess read FOnMessageAllow write FOnMessageAllow;
property OnMessageDeny: TOnGroupMessageAccess read FOnMessageDeny write FOnMessageDeny;
property OnMessageTypingState: TOnGroupMessageTypingState read FOnMessageTypingState write FOnMessageTypingState;
property OnVideoCommentNew: TOnCommentAction read FOnVideoCommentNew write FOnVideoCommentNew;
property OnVideoCommentEdit: TOnCommentAction read FOnVideoCommentEdit write FOnVideoCommentEdit;
property OnVideoCommentRestore: TOnCommentAction read FOnVideoCommentRestore write FOnVideoCommentRestore;
property OnVideoCommentDelete: TOnCommentDelete read FOnVideoCommentDelete write FOnVideoCommentDelete;
property OnPhotoCommentNew: TOnCommentAction read FOnPhotoCommentNew write FOnPhotoCommentNew;
property OnPhotoCommentEdit: TOnCommentAction read FOnPhotoCommentEdit write FOnPhotoCommentEdit;
property OnPhotoCommentRestore: TOnCommentAction read FOnPhotoCommentRestore write FOnPhotoCommentRestore;
property OnPhotoCommentDelete: TOnCommentDelete read FOnPhotoCommentDelete write FOnPhotoCommentDelete;
property OnBoardPostNew: TOnCommentAction read FOnBoardPostNew write FOnBoardPostNew;
property OnBoardPostEdit: TOnCommentAction read FOnBoardPostEdit write FOnBoardPostEdit;
property OnBoardPostRestore: TOnCommentAction read FOnBoardPostRestore write FOnBoardPostRestore;
property OnBoardPostDelete: TOnCommentDelete read FOnBoardPostDelete write FOnBoardPostDelete;
property OnMarketCommentNew: TOnCommentAction read FOnMarketCommentNew write FOnMarketCommentNew;
property OnMarketCommentEdit: TOnCommentAction read FOnMarketCommentEdit write FOnMarketCommentEdit;
property OnMarketCommentRestore: TOnCommentAction read FOnMarketCommentRestore write FOnMarketCommentRestore;
property OnMarketCommentDelete: TOnCommentDelete read FOnMarketCommentDelete write FOnMarketCommentDelete;
property OnGroupLeave: TOnGroupLeave read FOnGroupLeave write FOnGroupLeave;
property OnGroupJoin: TOnGroupJoin read FOnGroupJoin write FOnGroupJoin;
property OnUserBlock: TOnGroupUserBlock read FOnUserBlock write FOnUserBlock;
property OnUserUnBlock: TOnGroupUserUnBlock read FOnUserUnBlock write FOnUserUnBlock;
property OnGroupPollVoteNew: TOnGroupPollVoteNew read FOnGroupPollVoteNew write FOnGroupPollVoteNew;
property OnGroupOfficersEdit: TOnGroupOfficersEdit read FOnGroupOfficersEdit write FOnGroupOfficersEdit;
property OnGroupChangeSettings: TOnGroupChangeSettings read FOnGroupChangeSettings write FOnGroupChangeSettings;
property OnGroupChangePhoto: TOnGroupChangePhoto read FOnGroupChangePhoto write FOnGroupChangePhoto;
property OnGroupPayTransaction: TOnGroupPayTransaction read FOnGroupPayTransaction write FOnGroupPayTransaction;
property OnGroupAppPayload: TOnGroupAppPayload read FOnGroupAppPayload write FOnGroupAppPayload;
property OnGroupUnhandledEvents: TOnGroupUnhandledEvents read FOnGroupUnhandledEvents write FOnGroupUnhandledEvents;
property Version: string read FVersion write SetVersion;
end;
implementation
uses
System.DateUtils;
{ TCustomGroupEvents }
constructor TCustomGroupEvents.Create(AOwner: TComponent);
var
i: Integer;
begin
inherited;
if Assigned(AOwner) and (csDesigning in ComponentState) then
begin
for i := 0 to AOwner.ComponentCount - 1 do
if AOwner.Components[i] is TCustomVK then
begin
FVK := AOwner.Components[i] as TCustomVK;
Break;
end;
end;
FLongPollEvents := TLongPollEvents.Create;
FVersion := VK_LP_VERSION;
FLongPollServer := TVkLongPollServer.Create;
FLongPollServer.OnUpdate := FOnLongPollUpdate;
FLongPollServer.OnError := FOnError;
FLongPollServer.Logging := True;
FLongPollServer.DoSync := True;
FillEvents;
end;
destructor TCustomGroupEvents.Destroy;
begin
FLongPollEvents.Free;
FLongPollServer.Free;
inherited;
end;
procedure TCustomGroupEvents.DoEvent(Sender: TObject; Update: TJSONValue);
var
GroupId: Integer;
EventType: string;
EventId: string;
EventObject: TJSONValue;
begin
EventType := Update.GetValue<string>('type', '');
EventObject := Update.GetValue<TJSONValue>('object', nil);
GroupId := Update.GetValue<Integer>('group_id', 0);
EventId := Update.GetValue<string>('event_id', '');
if not Assigned(EventObject) then
raise TVkGroupEventsException.Create('Не был получен объект события');
if EventType.IsEmpty then
raise TVkGroupEventsException.Create('Не был получен тип события');
try
if FLongPollEvents.ContainsKey(EventType) then
FLongPollEvents.Items[EventType](GroupId, EventObject, EventId)
else
DoGroupUnhandledEvents(GroupId, Update);
except
on E: Exception do
VK.DoLog(Sender, 'Error TCustomGroupEvents.DoEvent ' + E.Message + #13#10 + Update.ToJSON);
end;
end;
procedure TCustomGroupEvents.DoAudioNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Audio: TVkAudio;
begin
if Assigned(FOnAudioNew) then
begin
Audio := TVkAudio.FromJsonString<TVkAudio>(EventObject.ToString);
try
FOnAudioNew(Self, GroupId, Audio, EventId);
finally
Audio.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoAppPayload(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkAppPayload;
begin
if Assigned(FOnGroupAppPayload) then
begin
Info.UserId := EventObject.GetValue<Integer>('user_id', -1);
Info.AppId := EventObject.GetValue<Integer>('app_id', -1);
Info.Payload := EventObject.GetValue<string>('payload', '');
Info.GroupId := EventObject.GetValue<Integer>('group_id', -1);
FOnGroupAppPayload(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoBoardPostDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkCommentInfo;
begin
if Assigned(FOnBoardPostDelete) then
begin
Info.Id := EventObject.GetValue<Integer>('id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('owner_id', -1);
Info.DeleterId := EventObject.GetValue<Integer>('deleter_id', -1);
Info.ObjectId := -1;
Info.UserId := -1;
FOnBoardPostDelete(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoBoardPostEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnBoardPostEdit) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('topic_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('topic_owner_id', -1);
try
FOnBoardPostEdit(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoBoardPostNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnBoardPostNew) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('topic_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('topic_owner_id', -1);
try
FOnBoardPostNew(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoBoardPostRestore(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnBoardPostRestore) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('topic_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('topic_owner_id', -1);
try
FOnBoardPostRestore(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoGroupChangePhoto(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Changes: TVkGroupChangePhoto;
begin
if Assigned(FOnGroupChangePhoto) then
begin
Changes := TVkGroupChangePhoto.Create;
Changes.UserId := EventObject.GetValue<Integer>('user_id', -1);
Changes.Photo := TVkPhoto.FromJsonObject<TVkPhoto>(EventObject.GetValue<TJSONObject>('photo', nil));
try
FOnGroupChangePhoto(Self, GroupId, Changes, EventId);
finally
Changes.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoGroupChangeSettings(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Changes: TVkGroupSettingsChange;
begin
if Assigned(FOnGroupChangeSettings) then
begin
Changes := TVkGroupSettingsChange.FromJsonString<TVkGroupSettingsChange>(EventObject.ToString);
try
FOnGroupChangeSettings(Self, GroupId, Changes, EventId);
finally
Changes.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoGroupJoin(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
UserId: Integer;
JoinType: TVkGroupJoinType;
begin
if Assigned(FOnGroupJoin) then
begin
UserId := EventObject.GetValue<Integer>('user_id', -1);
JoinType := TVkGroupJoinType.Create(EventObject.GetValue<string>('join_type ', ''));
FOnGroupJoin(Self, GroupId, UserId, JoinType, EventId);
end;
end;
procedure TCustomGroupEvents.DoGroupLeave(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
UserId: Integer;
IsSelf: Boolean;
begin
if Assigned(FOnGroupLeave) then
begin
UserId := EventObject.GetValue<Integer>('user_id', -1);
IsSelf := EventObject.GetValue<Integer>('self', -1) = 1;
FOnGroupLeave(Self, GroupId, UserId, IsSelf, EventId);
end;
end;
procedure TCustomGroupEvents.DoGroupOfficersEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkGroupOfficersEdit;
begin
if Assigned(FOnGroupOfficersEdit) then
begin
Info.AdminId := EventObject.GetValue<Integer>('admin_id', -1);
Info.LevelOld := TVkGroupLevel(EventObject.GetValue<Integer>('level_old', 0));
Info.LevelNew := TVkGroupLevel(EventObject.GetValue<Integer>('level_new', 0));
Info.UserId := EventObject.GetValue<Integer>('user_id', -1);
FOnGroupOfficersEdit(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoGroupUnhandledEvents(GroupId: Integer; JSON: TJSONValue);
begin
if Assigned(FOnGroupUnhandledEvents) then
FOnGroupUnhandledEvents(Self, GroupId, JSON);
end;
procedure TCustomGroupEvents.DoMarketCommentDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkCommentInfo;
begin
if Assigned(FOnMarketCommentDelete) then
begin
Info.Id := EventObject.GetValue<Integer>('id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('owner_id', -1);
Info.UserId := EventObject.GetValue<Integer>('user_id', -1);
Info.DeleterId := EventObject.GetValue<Integer>('deleter_id', -1);
Info.ObjectId := EventObject.GetValue<Integer>('item_id', -1);
FOnMarketCommentDelete(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoMarketCommentEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnMarketCommentEdit) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('item_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('market_owner_id', -1);
try
FOnMarketCommentEdit(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoMarketCommentNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnMarketCommentNew) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('item_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('market_owner_id', -1);
try
FOnMarketCommentNew(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoMarketCommentRestore(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnMarketCommentRestore) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue('item_id', -1);
Info.OwnerId := EventObject.GetValue('market_owner_id', -1);
try
FOnMarketCommentRestore(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoMessageAllow(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
UserId: Integer;
Key: string;
begin
if Assigned(FOnMessageAllow) then
begin
UserId := EventObject.GetValue('user_id', -1);
Key := EventObject.GetValue('key', '');
FOnMessageAllow(Self, GroupId, UserId, Key, EventId);
end;
end;
procedure TCustomGroupEvents.DoMessageDeny(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
UserId: Integer;
begin
if Assigned(FOnMessageDeny) then
begin
UserId := EventObject.GetValue('user_id', -1);
FOnMessageDeny(Self, GroupId, UserId, '', EventId);
end;
end;
procedure TCustomGroupEvents.DoMessageEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Message: TVkMessage;
begin
if Assigned(FOnMessageEdit) then
begin
Message := TVkMessage.FromJsonString<TVkMessage>(EventObject.ToString);
try
FOnMessageEdit(Self, GroupId, Message, EventId);
finally
Message.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoMessageNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Message: TVkMessage;
ClientInfo: TVkClientInfo;
begin
if Assigned(FOnMessageNew) then
begin
Message := TVkMessage.FromJsonObject<TVkMessage>(EventObject.GetValue<TJSONObject>('message'));
ClientInfo := TVkClientInfo.FromJsonObject<TVkClientInfo>(EventObject.GetValue<TJSONObject>('client_info'));
try
FOnMessageNew(Self, GroupId, Message, ClientInfo, EventId);
finally
Message.Free;
ClientInfo.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoMessageReply(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Message: TVkMessage;
begin
if Assigned(FOnMessageReply) then
begin
Message := TVkMessage.FromJsonString<TVkMessage>(EventObject.ToString);
try
FOnMessageReply(Self, GroupId, Message, EventId);
finally
Message.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoMessageTypingState(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
UserId: Integer;
State: string;
begin
if Assigned(FOnMessageTypingState) then
begin
UserId := EventObject.GetValue<Integer>('from_id', -1);
State := EventObject.GetValue<string>('state', '');
FOnMessageTypingState(Self, GroupId, UserId, State, EventId);
end;
end;
procedure TCustomGroupEvents.DoPhotoCommentDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkCommentInfo;
begin
if Assigned(FOnPhotoCommentDelete) then
begin
Info.Id := EventObject.GetValue<Integer>('id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('owner_id', -1);
Info.UserId := -1;
Info.DeleterId := EventObject.GetValue<Integer>('deleter_id', -1);
Info.ObjectId := EventObject.GetValue<Integer>('photo_id', -1);
FOnPhotoCommentDelete(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoPhotoCommentEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnPhotoCommentEdit) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('photo_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('photo_owner_id', -1);
try
FOnPhotoCommentEdit(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoPhotoCommentNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnPhotoCommentNew) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('photo_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('photo_owner_id', -1);
try
FOnPhotoCommentNew(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoPhotoCommentRestore(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnPhotoCommentRestore) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('photo_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('photo_owner_id', -1);
try
FOnPhotoCommentRestore(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoPhotoNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Photo: TVkPhoto;
begin
if Assigned(FOnPhotoNew) then
begin
Photo := TVkPhoto.FromJsonString<TVkPhoto>(EventObject.ToString);
try
FOnPhotoNew(Self, GroupId, Photo, EventId);
finally
Photo.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoPollVoteNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkGroupPollVoteNew;
begin
if Assigned(FOnGroupPollVoteNew) then
begin
Info.OwnerId := EventObject.GetValue<Integer>('owner_id', -1);
Info.UserId := EventObject.GetValue<Integer>('user_id', -1);
Info.PollId := EventObject.GetValue<Integer>('poll_id ', -1);
Info.OptionId := EventObject.GetValue<Integer>('option_id', -1);
FOnGroupPollVoteNew(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoUserBlock(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkGroupUserBlock;
begin
if Assigned(FOnUserBlock) then
begin
Info.AdminId := EventObject.GetValue<Integer>('admin_id', -1);
Info.UserId := EventObject.GetValue<Integer>('user_id', -1);
Info.UnblockDate := UnixToDateTime(EventObject.GetValue<Integer>('unblock_date ', 0), False);
Info.Reason := TVkUserBlockReason(EventObject.GetValue<Integer>('reason', 0));
Info.Comment := EventObject.GetValue<string>('comment', '');
FOnUserBlock(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoUserUnblock(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkGroupUserUnBlock;
begin
if Assigned(FOnUserUnBlock) then
begin
Info.AdminId := EventObject.GetValue<Integer>('admin_id', -1);
Info.UserId := EventObject.GetValue<Integer>('user_id', -1);
Info.ByEndDate := EventObject.GetValue<Integer>('by_end_date ', -1) = 1;
FOnUserUnBlock(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoVideoCommentDelete(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Info: TVkCommentInfo;
begin
if Assigned(FOnVideoCommentDelete) then
begin
Info.Id := EventObject.GetValue<Integer>('id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('owner_id', -1);
Info.DeleterId := EventObject.GetValue<Integer>('deleter_id', -1);
Info.UserId := EventObject.GetValue<Integer>('user_id', -1);
Info.ObjectId := EventObject.GetValue<Integer>('video_id', -1);
FOnVideoCommentDelete(Self, GroupId, Info, EventId);
end;
end;
procedure TCustomGroupEvents.DoVideoCommentEdit(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnVideoCommentEdit) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('video_id', -1);
Info.OwnerId := EventObject.GetValue<Integer>('video_owner_id', -1);
try
FOnVideoCommentEdit(Self, GroupId, Comment, Info, EventId);
finally
Comment.Free;
end;
end;
end;
procedure TCustomGroupEvents.DoVideoCommentNew(GroupId: Integer; EventObject: TJSONValue; const EventId: string);
var
Comment: TVkComment;
Info: TVkObjectInfo;
begin
if Assigned(FOnVideoCommentNew) then
begin
Comment := TVkComment.FromJsonString<TVkComment>(EventObject.ToString);
Info.Id := EventObject.GetValue<Integer>('video_id', -1);