import vk
import time
import random
import requests
token = 'bdd6a8bd5c834c4c49f0731c895d533b50c91a69739d38d1611d40b6465ea9886132f11fef602f23a7bae'
bot = vk.API(vk.Session(access_token = 'bdd6a8bd5c834c4c49f0731c895d533b50c91a69739d38d1611d40b6465ea9886132f11fef602f23a7bae'))
last_mid = 0
msg_info = bot.messages.get(count = 1)
#print(msg_info)
print(msg_info[1])
while True:
data = requests.get('https://api.vk.com/method/messages.getLongPollServer',
params={'access_token': token}).json()['response']
response = requests.get('https://{server}?act=a_check&key={key}&ts={ts}&wait=90&mode=2&version=2'.format(server=data['server'], key=data['key'], ts=data['ts'])).json()
updates = response['updates']
print(response)
if(len(updates) ==2):
if(updates[1][0] == 4):
msg_info = bot.messages.get(count = 1) #attachment =
msg_body = msg_info[1]['body']
#c_mid = msg_info[1]['mid']
if True:
#last_mid = c_mid
if msg_body[0:5] in['/пост','/post']:
bot.wall.post(message = msg_body[5:])
'''
if msg_body[0:7] in['/a_post']:
at_type = str(msg_info[1]['attachment']["type"])
if at_type in['photo']:
at = str(at_type + str(msg_info[1]['attachment'][at_type]['owner_id']) + '_'+str(msg_info[1]['attachment'][at_type]['pid']))
photo = bot.photos.copy(owner_id = msg_info[1]['attachment'][at_type]['owner_id'],photo_id =msg_info[1]['attachment'][at_type]['pid'],access_key = msg_info[1]['attachment'][at_type]['access_key'])
bot.wall.post(message = msg_body[8:],attachment = at_type+'446978051_'+str(photo))
print('work')
'''
if msg_body[0:5] in['/инфа']:
print(msg_info)
per = random.randint(1,4)
if per == 1:
inf = random.randint(0,40)
if per == 3 or per == 2:
inf = random.randint(40,75)
if per == 4:
inf = random.randint(90,100)
print(inf)
bot.messages.send(chat_id =1,message = "Инфа подтверждена на "+str(inf)+"%")
if msg_body[0:3] in['кто','ктО','кТо','кТО','Кто','КтО','КТо','КТО']:
#print(type(msg_info[1]['chat_id']))
listt = bot.messages.getChatUsers(chat_id = int(msg_info[1]['chat_id']),fields = 'screen_name')
user = listt[random.randint(0,len(listt)-1)]
f_n = user['first_name']
l_n = user['last_name']
while l_n in['Оверлорд']:
user = listt[random.randint(0,len(listt)-1)]
f_n = user['first_name']
l_n = user['last_name']
msg = ['Я думаю это','Скорее всего это','Может быть это','Инфа сотка это','Ну даже не занаю,наверное это','По любому']
mmsg = msg[random.randint(0,len(msg)-1)]
bot.messages.send(chat_id = int(msg_info[1]['chat_id']),message = mmsg+" "+f_n+" " + l_n)
if msg_body[0:13] in['Слава Украине','слава Украине','Слава украине','слава украине']:
bot.messages.send(chat_id =int(msg_info[1]['chat_id']),message = "Героям слава!",attachment = 'audio166313120_274537504')
if msg_body[0:11] in['Слава КПСС','слава КПСС','слава кпсс','Слава кпсс']:
bot.messages.send(chat_id = int(msg_info[1]['chat_id']),message = 'Ленин жив!',attachment = 'audio16689125_106992266')
data['ts'] = response['ts']