fix blocking async bug, add private message text handler

This commit is contained in:
Rykov7
2024-03-27 23:24:02 +03:00
parent 3231d8c263
commit ba256a7456
2 changed files with 9 additions and 1 deletions
+7
View File
@@ -385,3 +385,10 @@ async def handle_msg(message: types.Message):
"""Count messages, Stan."""
update_stats(message)
await act(message)
@bot.message_handler(content_types=["text", "sticker", "photo", "animation", "video", "audio", "document"],
chat_types=["private"])
async def handle_all_msg(message: types.Message):
"""Личка выводится в лог."""
logging.info(LOG_COMM % ('PM', message.from_user.id, message.from_user.full_name, message.text))
+2 -1
View File
@@ -1,3 +1,4 @@
import asyncio
import logging
import telebot
@@ -15,6 +16,6 @@ async def webhook(update: dict):
"""Parse POST requests from Telegram."""
if update:
update = telebot.types.Update.de_json(update)
await bot.process_new_updates([update])
asyncio.ensure_future(bot.process_new_updates([update]))
else:
return None