Python
2
Вклад в тег
def write_msg(self, user_id, message, key):
try:
self.vk.method('messages.send', {'user_id': user_id, 'message': message, 'keyboard': key, 'random_id': random.randint(0, 100000000)})
except Exception as ex:
print("error (write_msg, {0}, {1}):".format(user_id, message), ex)
for event in self.longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW and event.to_me:
id = event.user_id
msg = event.text.lower()
if msg == "подписаться":
write_msg(id, 'Подписались', keyboard2)