Advertisement
Guest User

kick

a guest
Jun 14th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. import time
  2. import json
  3. import requests
  4. from pickle import load
  5. from pickle import dump
  6. from vklancer import api
  7. from vklancer import utils
  8. global z,l
  9. def set_vk_token(access_token, AUTH_FILE):
  10. with open(AUTH_FILE, 'wb') as output:
  11. dump(access_token, output)
  12. def get_vk_token(AUTH_FILE):
  13. token = None
  14. try:
  15. with open(AUTH_FILE, 'rb') as pkl_file:
  16. token = load(pkl_file)
  17. except Exception:
  18. pass
  19. return token
  20. def load_config(failname):
  21. with open(failname) as data_file:
  22. return json.load(data_file)
  23. def method_errors(data):
  24. if 'error' not in data:
  25. return False
  26. else:
  27. print(data['error'])
  28. return True
  29. m=0
  30. l=0
  31. ids=[]
  32. like={'response': 1}
  33. mus=[]
  34. output = open('2.txt', 'w')
  35. ban = []
  36. with open('list2.json') as f:
  37. ban = f.read().splitlines()
  38. print(ban)
  39. config = load_config('config2.json')
  40.  
  41. access_token = get_vk_token(config['auth_file'])
  42. if not access_token:
  43. access_token = utils.oauth(login=config['login'], password=config['password'], app_id=config['appid'], scope=config['scope'])
  44.  
  45.  
  46. if access_token:
  47. print("[+] Auth succesfull.")
  48.  
  49. vk = api.API(token=access_token, version='5.8')
  50. set_vk_token(access_token, config['auth_file'])
  51.  
  52. dusers = vk.groups.getMembers(group_id=config['group_id'], offset=config['users_per_request'],count=config['users_per_request'])
  53. d = vk.execute.newFunc(user=177727676)
  54. print(d)
  55. users_total = dusers['response']['count']
  56. print(users_total)
  57. for x in range(0, users_total, int(config['users_per_request'])):
  58. print(x)
  59. fusers = vk.groups.getMembers(group_id=config['group_id'], offset=x ,count=config['users_per_request'])
  60.  
  61.  
  62. for bitem in fusers['response']['users']:
  63. l+=1
  64. print(l)
  65.  
  66. bb=0
  67. try:
  68. time.sleep(0.33)
  69. c = vk.execute.newFunc(user=int(bitem)) '''возвращает топ 5 групп'''
  70. print(c)
  71.  
  72. except Exception:
  73. print('hyi')
  74. time.sleep(3)
  75.  
  76.  
  77.  
  78. for item in c['response']['items']:
  79. if bb>0:
  80. break
  81.  
  82. for key in ban:
  83.  
  84. if key in str(item): '''если группа из топ 5 в списке бана'''
  85. d = vk.execute.kick(user=int(bitem), gid=config['group_id']) '''кикает'''
  86. print('pidor', bitem)
  87. output.write('https://vk.com/id'+str(bitem)+'\n')
  88. m+=1
  89. bb=1
  90. break
  91.  
  92.  
  93.  
  94. print('vsego pidorov = ', m)
  95.  
  96.  
  97.  
  98. output.close()
  99. input(l)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement