Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import vk_api, json
- import random
- from vk_api.longpoll import VkLongPoll, VkEventType
- vk_session = vk_api.VkApi(token = '4618438e9a144cb8df60e0ab89571ec7b4a1b3fd6b088267c949de581d9879c46fdcb23daba64602bb9d5')
- vk = vk_session.get_api() #Было session_api
- longpoll = VkLongPoll(vk_session)
- list = ['Камень', 'Ножницы', 'Бумага']
- scoreboard = {}
- scoreboard['score'] = 0
- def sender(id, text):
- vk.messages.send(user_id = id, message = text, random_id = 0)#Отправка сообщений
- def send_stick(id, number):
- vk.messages.send(user_id = id, sticker_id = number, random_id = 0) #Отправка стикеров
- def send_photo(id, url):
- vk.messages.send(user_id = id, attachment = url, random_id = 0) #Отправка фото
- def rock_paper_scissors(id, element)
- b = random.choice(list)
- if (mes =='камень' and b =='Камень') or (mes == 'ножницы' and b =='Ножницы') or (mes == 'бумага' and b == 'Бумага'):
- sender(id, b)
- sender(id, 'Ничья!')
- elif (mes == 'камень' and b =='Бумага') or (mes == 'бумага' and b == 'Ножницы') or (mes == 'ножницы' and b == 'Камень'):
- scoreboard['score'] = scoreboard['score'] - 1
- sender(id, b)
- sender(id, 'Компьютер победил! Попробуй еще раз')
- elif (mes == 'камень' and b == 'Ножницы') or (mes == 'ножницы' and b == 'Бумага') or (mes == 'бумага' and b== 'Камень'):
- scoreboard['score'] = scoreboard['score'] + 1
- sender(id, b)
- ender(id, 'Ты победил! Но получится ли в следующий раз?')
- elif mes == 'конец игры':
- for event in longpoll.listen():
- if event.type == VkEventType.MESSAGE_NEW:
- if event.to_me:
- mes = event.text.lower() #mes - сообщение
- id = event.user_id
- #задаем переменную игрока
- player = False
- if mes == 'привет':
- sender(id, 'И тебе привет 😷. Чтобы узнать мои комнды напиши: "помощь"')
- elif mes == 'помощь':
- sender(id, '1.Скинь стикер\n2.Скинь пикчу\n3.Игры')
- elif mes == 'пока':
- sender(id, 'До свидания')
- elif mes == 'скинь стикер':
- send_stick(id, 8651)
- elif mes == 'скинь пикчу':
- send_photo(id, 'photo-200079360_457239018')
- elif mes == 'игры':
- sender(id, '1.Камень, ножницы✂, бумага📃')
- elif mes == 'камень ножницы бумага' or mes == 'камень, ножницы, бумага':
- sender(id, 'Чтобы играть введите "играть", а после выберите камень, ножницы или бумагу\nЕсли хотите закончить игру напишите "конец игры"')
- elif mes == 'играть камень':
- rock_paper_scissors(id, 'камень')
- elif mes == 'играть ножницы':
- rock_paper_scissors(id, 'ножницы')
- elif mes == 'играть бумага':
- rock_paper_scissors(id, 'бумага')
- else:
- sender(id, 'Непонел')
Advertisement
Add Comment
Please, Sign In to add comment