@PensioneR22

Почему не вызываются при исключение приглашение пользователя def process_chat_event?

def process_chat_event(self, event):
try:
if event.type == VkBotEventType.CHAT_INVITE_USER:
chat_id = event.chat_id
user_id = event.obj['user_id']
print(f"Received chat invite event for user {user_id} in chat {chat_id}")

if self.is_user_banned(user_id):
message = f"⚠️ Пользователь @id{user_id} заблокирован."
self.send_message(chat_id + 2000000000, message)

elif event.type == VkBotEventType.CHAT_KICK_USER:
chat_id = event.chat_id
user_id = event.obj['user_id']
print(f"Received chat kick event for user {user_id} in chat {chat_id}")

else:
print(f"Ignored event type: {event.type}")

except VkApiError as e:
print(f"Ошибка VK API при обработке события в беседе: [{e.code}] {e}")
except Exception as e:
print(f"Произошла ошибка при обработке события в беседе: {e}")

--------

def start(self):
print("Бот запущен")
for event in self.longpoll.listen():
try:
if event.type == VkBotEventType.MESSAGE_NEW and event.from_chat:
self.process_command(event)
elif event.type == VkBotEventType.CHAT_INVITE_USER and event.from_chat:
self.process_chat_event(event)
else:
print(f"Пропущено событие неизвестного типа: {event.type}")
except Exception as e:
print(f"Произошла ошибка в обработке события: {e}")
  • Вопрос задан
  • 28 просмотров
Пригласить эксперта
Ответы на вопрос 1
Надо расставить отступы.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы