from vk_api.keyboard import VkKeyboardColor, VkKeyboard
from token_0 import token
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
import random
sess = vk_api.VkApi(token= token)
vk = sess.get_api()
longpoll = VkLongPoll(sess)
print('Бот запущен!')
def send(id,text, keyboard=None):
post = {'user_id' : id,
'message' : text,
'random_id' : 0
}
if keyboard != None:
post["keyboard"] = keyboard.get_keyboard()
else:
post = post
sess.method('messages.send',post)
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
try:
msg = event.text.lower()
id = event.user_id
except:
pass
if msg == "Старт" or msg == "Меню":
keyboard = VkKeyboard()
keyboard.add_button("Спонсор",VkKeyboardColor.PRIMARY)
send(id, "Меню", keyboard)
if msg == "Спонсор":
keyboard = VkKeyboard()
keyboard.add_button("Меню",VkKeyboardColor.NEGATIVE)
send(id, "Нету", keyboard)
else:
keyboard = VkKeyboard()
keyboard.add_button("Меню",VkKeyboardColor.POSITIVE)
send(id, "Я вас не понял", keyboard)
if event.type == VkEventType.MESSAGE_NEW and event.to_me:
from vk_api.keyboard import VkKeyboardColor, VkKeyboard
from token_0 import token
import vk_api
from vk_api.longpoll import VkLongPoll, VkEventType
import random
sess = vk_api.VkApi(token= token)
vk = sess.get_api()
longpoll = VkLongPoll(sess)
print('Бот запущен!')
def send(id,text, keyboard=None):
post = {'user_id' : id,
'message' : text,
'random_id' : 0
}
if keyboard != None:
post["keyboard"] = keyboard.get_keyboard()
else:
post = post
sess.method('messages.send',post)
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW and event.to_me:
try:
msg = event.text.lower()
id = event.user_id
except:
pass
if msg == "Старт" or msg == "Меню":
keyboard = VkKeyboard()
keyboard.add_button("Спонсор",VkKeyboardColor.PRIMARY)
send(id, "Меню", keyboard)
if msg == "Спонсор":
keyboard = VkKeyboard()
keyboard.add_button("Меню",VkKeyboardColor.NEGATIVE)
send(id, "Нету", keyboard)
else:
keyboard = VkKeyboard()
keyboard.add_button("Меню",VkKeyboardColor.POSITIVE)
send(id, "Я вас не понял", keyboard)