feat(bot): add proxy limit
This commit is contained in:
@@ -18,7 +18,7 @@ from aiogram.types import (
|
||||
)
|
||||
from convex import ConvexInt64
|
||||
|
||||
from bot.handlers.proxy.handler import get_proxy_config
|
||||
from bot.handlers.proxy.handler import get_proxy_config, increment_proxy_count
|
||||
from bot.modules.ai import (
|
||||
SUMMARIZE_PROMPT,
|
||||
AgentDeps,
|
||||
@@ -426,6 +426,8 @@ async def process_message( # noqa: C901, PLR0912, PLR0913, PLR0915
|
||||
await proxy_config.proxy_bot.send_message(
|
||||
proxy_config.target_chat_id, f"👤 {text}"
|
||||
)
|
||||
await increment_proxy_count(chat_id)
|
||||
proxy_config = get_proxy_config(chat_id)
|
||||
|
||||
rag_connections = await convex.query(
|
||||
"ragConnections:getActiveForUser", {"userId": convex_user_id}
|
||||
@@ -550,6 +552,7 @@ async def process_message( # noqa: C901, PLR0912, PLR0913, PLR0915
|
||||
await proxy_config.proxy_bot.send_message(
|
||||
proxy_config.target_chat_id, part
|
||||
)
|
||||
await increment_proxy_count(chat_id)
|
||||
|
||||
except Exception as e: # noqa: BLE001
|
||||
await state.stop_typing()
|
||||
@@ -663,6 +666,7 @@ async def on_album_message(
|
||||
await proxy_config.proxy_bot.send_media_group(
|
||||
proxy_config.target_chat_id, media
|
||||
)
|
||||
await increment_proxy_count(message.chat.id)
|
||||
|
||||
active_chat_id = user["activeChatId"]
|
||||
await convex.mutation(
|
||||
@@ -732,6 +736,7 @@ async def on_photo_message(message: types.Message, bot: Bot) -> None:
|
||||
BufferedInputFile(image_bytes, "photo.jpg"),
|
||||
caption=f"👤 {caption}",
|
||||
)
|
||||
await increment_proxy_count(message.chat.id)
|
||||
|
||||
active_chat_id = user["activeChatId"]
|
||||
await convex.mutation(
|
||||
|
||||
Reference in New Issue
Block a user