import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
vk_session = vk_api.VkApi(token = "...")
longpoll = vk_api.VkApi(vk_session, "...")
def sender(id, text):
vk_session.method('messages.send', {'chad_id' : id, 'message' : text, 'random_id' : 0})
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.from_chat:
id = event.chat_id
msg = event.object.message['text'].lower()
try:
dey = event.message.action['type']
invite_id = event.message.action['member_id']
except:
dey = ''
invite_id = -100
if dey == 'chat_invite_user':
sender(id, f'✔Приветствуем вас в нашей беседе, @id {invite_id} пожалуйста прочитайте правила беседы и не нарушайте их.')