from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
import vk_api
token = "********"
group_id = "********"
vk_session = vk_api.VkApi(token = token)
longpoll = VkBotLongPoll(vk_session, group_id)
vk = vk_session.get_api()
def main():
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW and event.from_chat:
user_id = event.message.from_id
if "-" in str(user_id):
pass
else:
chat(event)
def chat(event):
user_id = event.message.from_id
chat_id = event.message.peer_id % 2000000000
user_info = vk.users.get(user_ids=user_id)
user_info = user_info[0]
first_name = user_info["first_name"]
id = event.chat_id
vk.messages.send(
message= (f"@id{user_id} ({first_name}), СООБЩЕНИЕ"),
chat_id=chat_id,
random_id= 0
)
if __name__ == '__main__':
main()