Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #coding:utf-8
  2. import time
  3. import datetime
  4. import vk_api
  5. import random
  6. import calendar
  7. vk = vk_api.VkApi(token = '***')
  8. vk.authorization()
  9.  
  10.  
  11. tools = vk_api.VkTools(vk)
  12.  
  13. users=[]
  14.  
  15. value_get = {
  16. 'out' : 0,
  17. 'count' :1,
  18. }
  19.  
  20. while True:
  21.  
  22. now_time = datetime.datetime.now()
  23. req = vk.method('messages.get',value_get)
  24. user_id = req['items'][0]['user_id']
  25. offset = random.randint(1,60)
  26. if req['items'][0]['title'] == ' ... ' and user_id not in users:
  27. req_a = vk.method('audio.getPopular',{"genre_id":1,"count":1,"offset":offset} )
  28. audio = ('audio'+str(req_a[0]['owner_id'])+"_"+str(req_a[0]['id']))
  29. print(audio)
  30. value_send = {
  31. 'user_id':user_id,
  32. 'message':'Жени пока нет на месте. Ожидайте ответа.',
  33. 'attachment':audio
  34. }
  35. send = vk.method('messages.send',value_send)
  36. users.append(user_id)
  37. time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement