Advertisement
JolyJDIA

Untitled

Sep 24th, 2020 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.59 KB | None | 0 0
  1.     public static final int CHUNK = 20;
  2.     static boolean add = true;
  3.     static int targetDaun = 559833339;
  4.  
  5.     public static void main(String[] args) throws ClientException, ApiException, InterruptedException {
  6.         //vkApiClient.status().set(VALERA).text("Сущее сосущее0").execute();
  7.         List<Photo> memes = vkApiClient.photos().get(VALERA).ownerId(VALERA.getId()).albumId("saved").execute().getItems();
  8.  
  9.         List<Photo> items = vkApiClient.photos().get(VALERA).ownerId(targetDaun).albumId("profile").execute().getItems();
  10.  
  11.         //Photo coronoVirus = items.get(items.size()-1);
  12.  
  13.         List<AbstractQueryBuilder> batch = new ArrayList<>(CHUNK);
  14.         List<WallComment> wallComments = Collections.emptyList();
  15.  
  16.         for(Photo coronoVirus : items) {
  17.             for (int i = 0, len = add ? 999
  18.                     : (wallComments = vkApiClient.photos().getComments(VALERA, coronoVirus.getId())
  19.                     .ownerId(targetDaun)
  20.                     .execute().getItems()).size();
  21.                  i < len; ++i) {
  22.                 if (add) {
  23.                     System.out.println("create comment");
  24.                     PhotosCreateCommentQuery createCommentQuery = vkApiClient.photos()
  25.                             .createComment(VALERA, coronoVirus.getId())
  26.                             .ownerId(targetDaun);
  27.                     if (ThreadLocalRandom.current().nextBoolean()) {
  28.                         createCommentQuery.message(ThreadLocalRandom.current().ints(256, 0, 122)
  29.                                 .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
  30.                                 .toString()
  31.                                 .repeat(5)
  32.                         );
  33.                     } else {
  34.                         Photo rand = memes.get(ThreadLocalRandom.current().nextInt(memes.size()));
  35.                         createCommentQuery.attachments("photo" + rand.getOwnerId() + '_' + rand.getId());
  36.                     }
  37.                     batch.add(createCommentQuery);
  38.                 } else {
  39.                     System.out.println("delete comment");
  40.                     batch.add(vkApiClient.photos().deleteComment(VALERA, wallComments.get(i).getId()).ownerId(targetDaun));
  41.                 }
  42.                 if (i % CHUNK == 0 || i == len - 1) {
  43.                     System.out.println("push");
  44.                     vkApiClient.execute().batch(VALERA, batch).execute();
  45.                     batch.clear();
  46.                     Thread.sleep(2000);
  47.                 }
  48.             }
  49.             Thread.sleep(500);
  50.         }
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement