Answer the question
In order to leave comments, you need to log in
What operator should be used for enumeration instead of or?
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
import random
vk = vk_api.VkApi(token="token")
vk._auth_token()
vk.get_api()
longpoll = VkBotLongPoll(vk, vk group id)
while True:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.object.peer_id != event.object.from_id:
if event.object.text.lower() == "hello bot" or "hello bot " or "hey bot" or "Hey bot":
vk.method("messages.send", {"peer_id": event.object.peer_id, "message": "hi",
"random_id": 0 })
Answer the question
In order to leave comments, you need to log in
...
if event.object.text.lower() in ["привет бот", "Привет бот", "эй бот", "Эй бот"]:
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question