def get_user(pattern: str) -> int:
if "vk.com/" in pattern:
domen = pattern.split("/")[-1]
print(domen)
return vk.users.get(user_ids=domen, fields=0, name_case=0)["id"]
while True:
try:
for event in longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
text = event.text.split(' ')
if text[0] == "Вернуть" or text[0] == "вернуть":
vk.messages.addChatUser(
chat_id=event.chat_id,
user_id=get_user(text[1]),
visible_messages_count=250
)
except Exception as e:
print(repr(e))