if event.type == VkBotEventType.MESSAGE_NEW and (action := event.obj['message'].get('action')):
if action['type'] == 'chat_invite_user' and action["member_id"] == -12345678: #вместо -12345678 айди группы с минусом
vk.messages.send(
peer_id=event.message.peer_id,
random_id=get_random_id(),
message="Привет")
import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
from vk_api.utils import get_random_id
vk_session = vk_api.VkApi(token="tokengroup")
longpoll = VkBotLongPoll(vk_session, 'idgroup')
vk = vk_session.get_api()
while True:
try:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW and event.raw['object']['message']['action']['type'] == 'chat_invite_user' and event.raw['object']['message']['action']['member_id'] == -12345678: #вместо -12345678 впишите id своей группы
vk.messages.send(
peer_id=event.message.peer_id,
random_id=get_random_id(),
message="Тест"
)
except Exception as e:
print(e)