vk_chat_bot/handlers/default.py
Kirill Kirilenko 0894e3b775 Реорганизация проекта.
Обработчики разделены на несколько модулей.
2025-08-28 03:21:48 +03:00

27 lines
804 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from vkbottle.bot import Message
import database
import utils
from labeler import labeler
# Обычные сообщения (не команды и не действия)
@labeler.chat_message()
async def any_message_handler(message: Message):
chat_id = message.peer_id
chat = database.create_chat_if_not_exists(chat_id)
if chat['active'] == 0:
return
# Игнорировать ботов
if message.from_id < 0:
return
# Не учитывать служебные сообщения
if message.action is not None:
return
user_id = message.from_id
database.create_user_if_not_exists(chat_id, user_id)
database.DB.user_set_last_message(chat_id, user_id, utils.posix_time())
database.DB.user_increment_messages(chat_id, user_id)