29 lines
874 B
Python
29 lines
874 B
Python
from vkbottle.bot import Message
|
||
from vkbottle.framework.labeler import BotLabeler
|
||
|
||
import utils
|
||
import vk.vk_database as database
|
||
|
||
labeler = BotLabeler()
|
||
|
||
|
||
# Обычные сообщения (не команды и не действия)
|
||
@labeler.chat_message()
|
||
async def any_message_handler(message: Message):
|
||
chat_id = message.peer_id
|
||
chat = database.DB.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.DB.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)
|