Answer the question
In order to leave comments, you need to log in
How to make sure that the bot does not break if another community writes to the conversation?
The bot crashes if another community writes to the conversation, cannot process its message
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW: #Слушаем longpoll, если пришло сообщение то:
response = str(event.message.text)
user_id = str(event.message.from_id)
user = vk.users.get(user_ids=user_id)
elif word == 'дата' or word == 'время' or word == '!time' or word == 'какой сегодня день':
if event.from_chat:
vk.messages.send( #Отправляем сообщение
chat_id=event.chat_id, #Здесь chat_id
random_id=get_random_id(),
message='Сегодня: ' + message_time,
)
vk_api.exceptions.ApiError: [113] Invalid user id
Answer the question
In order to leave comments, you need to log in
Check in event where the message came from, from a group or user
https://vk-api.readthedocs.io/en/latest/_modules/v...
How do you even get it started?
1. The indents are not correct
2. Store the message in the response, and compare it with some kind of word
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question