Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final int CHUNK = 20;
- static boolean add = true;
- static int targetDaun = 559833339;
- public static void main(String[] args) throws ClientException, ApiException, InterruptedException {
- //vkApiClient.status().set(VALERA).text("Сущее сосущее0").execute();
- List<Photo> memes = vkApiClient.photos().get(VALERA).ownerId(VALERA.getId()).albumId("saved").execute().getItems();
- List<Photo> items = vkApiClient.photos().get(VALERA).ownerId(targetDaun).albumId("profile").execute().getItems();
- //Photo coronoVirus = items.get(items.size()-1);
- List<AbstractQueryBuilder> batch = new ArrayList<>(CHUNK);
- List<WallComment> wallComments = Collections.emptyList();
- for(Photo coronoVirus : items) {
- for (int i = 0, len = add ? 999
- : (wallComments = vkApiClient.photos().getComments(VALERA, coronoVirus.getId())
- .ownerId(targetDaun)
- .execute().getItems()).size();
- i < len; ++i) {
- if (add) {
- System.out.println("create comment");
- PhotosCreateCommentQuery createCommentQuery = vkApiClient.photos()
- .createComment(VALERA, coronoVirus.getId())
- .ownerId(targetDaun);
- if (ThreadLocalRandom.current().nextBoolean()) {
- createCommentQuery.message(ThreadLocalRandom.current().ints(256, 0, 122)
- .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
- .toString()
- .repeat(5)
- );
- } else {
- Photo rand = memes.get(ThreadLocalRandom.current().nextInt(memes.size()));
- createCommentQuery.attachments("photo" + rand.getOwnerId() + '_' + rand.getId());
- }
- batch.add(createCommentQuery);
- } else {
- System.out.println("delete comment");
- batch.add(vkApiClient.photos().deleteComment(VALERA, wallComments.get(i).getId()).ownerId(targetDaun));
- }
- if (i % CHUNK == 0 || i == len - 1) {
- System.out.println("push");
- vkApiClient.execute().batch(VALERA, batch).execute();
- batch.clear();
- Thread.sleep(2000);
- }
- }
- Thread.sleep(500);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement