Проблема с ботом ВК
Использую vk_api, longpoll, но:
- if event.type == VkBotEventType.MESSAGE_EDIT: выполняется только если пишешь боту в лс, а не в группу.
- if event.type == VkBotEventType.MESSAGE_NEW: выполняется только если пишешь в общий чат.
- if event.type == VkBotEventType.PHOTO_NEW: не выполняется ни так, ни так.
Подскажите, в чем может быть проблема? Нужно только, чтобы всё отслеживалось в общем чате.
Вот мой код:
import vk_api
from vk_api.keyboard import VkKeyboard, VkKeyboardColor
from vk_api.utils import get_random_id
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
vk_session = vk_api.VkApi(token='<--->')
vk = vk_session.get_api()
longpoll = VkBotLongPoll(vk_session, '<--->')
keyboard = VkKeyboard(one_time=True)
keyboard.add_button('Привет', color=VkKeyboardColor.NEGATIVE)
keyboard.add_button('Клавиатура', color=VkKeyboardColor.POSITIVE)
keyboard.add_line()
keyboard.add_location_button()
keyboard.add_line()
keyboard.add_vkpay_button(hash="action=transfer-to-group&group_id=<--->")
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.message["text"] == 'Hi':
if event.from_chat:
vk.messages.send(
key='<--->',
server='<--->',
ts='1',
random_id=get_random_id(),
message='Привет!',
chat_id=event.chat_id
)
if 'Keys' == event.message["text"]:
if event.from_chat:
vk.messages.send(
keyboard=keyboard.get_keyboard(),
key='<--->',
server='<--->',
ts='1',
random_id=get_random_id(),
message='Держи',
chat_id=event.chat_id
)
if event.type == VkBotEventType.MESSAGE_EDIT:
if event.from_chat:
print('edited')