Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #coding:utf-8
- import time
- import datetime
- import vk_api
- import random
- import calendar
- vk = vk_api.VkApi(token = '***')
- vk.authorization()
- tools = vk_api.VkTools(vk)
- users=[]
- value_get = {
- 'out' : 0,
- 'count' :1,
- }
- while True:
- now_time = datetime.datetime.now()
- req = vk.method('messages.get',value_get)
- user_id = req['items'][0]['user_id']
- offset = random.randint(1,60)
- if req['items'][0]['title'] == ' ... ' and user_id not in users:
- req_a = vk.method('audio.getPopular',{"genre_id":1,"count":1,"offset":offset} )
- audio = ('audio'+str(req_a[0]['owner_id'])+"_"+str(req_a[0]['id']))
- print(audio)
- value_send = {
- 'user_id':user_id,
- 'message':'Жени пока нет на месте. Ожидайте ответа.',
- 'attachment':audio
- }
- send = vk.method('messages.send',value_send)
- users.append(user_id)
- time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement