Add dual-prefix AI command
This commit is contained in:
@@ -7,6 +7,7 @@ from typing import Any
|
||||
|
||||
from pyrogram import Client, idle
|
||||
|
||||
from app.ai import AIService
|
||||
from app.commands import DEFAULT_REGISTRY, CommandRegistry, RuntimeAclStore
|
||||
from app.config import AccountConfig, AppConfig
|
||||
from app.handlers import register_common_handlers
|
||||
@@ -28,11 +29,13 @@ class AccountState:
|
||||
@dataclass(slots=True)
|
||||
class AccountManager:
|
||||
config: AppConfig
|
||||
ai_service: AIService | None = field(init=False)
|
||||
command_registry: CommandRegistry = field(init=False)
|
||||
states: list[AccountState] = field(init=False)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
self.command_registry = DEFAULT_REGISTRY
|
||||
self.ai_service = AIService(self.config.ai) if self.config.ai is not None else None
|
||||
self.states = [AccountState(config=account) for account in self.config.accounts]
|
||||
|
||||
def _make_client(self, account: AccountConfig) -> Client:
|
||||
@@ -121,6 +124,8 @@ class AccountManager:
|
||||
parts.append(
|
||||
f"acl={stats['allow_rules']} allow / {stats['deny_rules']} deny"
|
||||
)
|
||||
if self.ai_service is not None and self.config.ai is not None:
|
||||
parts.append(f"ai={self.config.ai.default_model}")
|
||||
if state.me is not None:
|
||||
display_name = (
|
||||
getattr(state.me, "full_name", None)
|
||||
|
||||
Reference in New Issue
Block a user