Guest User

Untitled

a guest
Aug 15th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.66 KB | None | 0 0
  1. import asyncio
  2. from aiovk import API, ImplicitSession
  3. from time import sleep
  4.  
  5. async def anticomments():
  6.     print ("Enter login:")
  7.     login = input()
  8.     print ("Enter password:")
  9.     password = input()
  10.     print ("Enter app id:")
  11.     app_id = input()
  12.    
  13.     session = ImplicitSession(login, password, app_id, ['photos', 'video', 'wall', 'groups'])
  14.     await session.authorize()
  15.  
  16.     api = API(session)
  17.  
  18.     user_var = await api.users.get()
  19.     user_id = user_var[0]['id']
  20.  
  21.     while True:
  22.         comments = await api.newsfeed.getComments(count = 100, start_time=1262307661, last_comments_count=0)
  23.         if comments['items'] == []:
  24.             break
  25.         for i in comments['items']:
  26.             offset = 0
  27.             if i['type'] == 'topic':
  28.                 while True:
  29.                     topic = await api.board.getComments(group_id=i['source_id']*-1, topic_id=i['post_id'], offset=offset, count=100)
  30.                     sleep(2)
  31.                     if topic['items'] == []:
  32.                         offset = 0
  33.                         await api.newsfeed.unsubscribe(type=i['type'], item_id=i['source_id'])
  34.                         break
  35.                     for j in topic['items']:
  36.                         if j['from_id'] == user_id:
  37.                             await api.board.deleteComment(group_id=i['source_id']*-1, topic_id=i['post_id'], comment_id=j['id'])
  38.                             sleep(2)
  39.                     offset = offset + 100
  40.             if i['type'] == 'post':
  41.                 while True:
  42.                     post = await api.wall.getComments(owner_id=i['source_id'], post_id=i['post_id'], offset=offset, count=100)
  43.                     sleep(2)
  44.                     if post['items'] == []:
  45.                         offset = 0
  46.                         await api.newsfeed.unsubscribe(type=i['type'], item_id=i['source_id'])
  47.                         break
  48.                     for j in post['items']:
  49.                         if j['from_id'] == user_id:
  50.                             await api.wall.deleteComment(owner_id=i['source_id'], comment_id=j['id'])
  51.                             sleep(2)
  52.                     offset = offset + 100
  53.             if i['type'] == 'photo':
  54.                 while True:
  55.                     photo = await api.photos.getComments(owner_id=i['source_id'], photo_id=i['post_id'], offset=offset, count=100)
  56.                     sleep(2)
  57.                     if photo['items'] == []:
  58.                         offset = 0
  59.                         await api.newsfeed.unsubscribe(type=i['type'], item_id=i['source_id'])
  60.                         break
  61.                     for j in photo['items']:
  62.                         if j['from_id'] == user_id:
  63.                             await api.photos.deleteComment(owner_id=i['source_id'], comment_id=j['id'])
  64.                             sleep(2)
  65.                     offset = offset + 100
  66.             if i['type'] == 'video':
  67.                 while True:
  68.                     videos = await api.video.getComments(owner_id=i['source_id'], video_id=i['post_id'], offset=offset, count=100)
  69.                     sleep(2)
  70.                     if videos['items'] == []:
  71.                         offset = 0
  72.                         await api.newsfeed.unsubscribe(type=i['type'], item_id=i['source_id'])
  73.                         break
  74.                     for j in videos['items']:
  75.                         if j['from_id'] == user_id:
  76.                             await api.video.deleteComment(owner_id=i['source_id'], comment_id=j['id'])
  77.                             sleep(2)
  78.                     offset = offset + 100
  79.  
  80.     session.close()
  81.  
  82. loop = asyncio.get_event_loop()
  83. loop.run_until_complete(anticomments())
Advertisement
Add Comment
Please, Sign In to add comment