Add GitHub webhook receiver

This commit is contained in:
2026-07-01 21:41:01 +02:00
parent 36170f83d1
commit 62ea12033f
9 changed files with 706 additions and 7 deletions

View File

@@ -10,6 +10,7 @@ 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.github_webhook import GitHubWebhookServer
from app.handlers import register_common_handlers
log = logging.getLogger(__name__)
@@ -32,11 +33,13 @@ class AccountManager:
ai_service: AIService | None = field(init=False)
command_registry: CommandRegistry = field(init=False)
states: list[AccountState] = field(init=False)
github_webhook_server: GitHubWebhookServer = 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]
self.github_webhook_server = GitHubWebhookServer(self, self.config.github_webhook)
def _make_client(self, account: AccountConfig) -> Client:
api_id = account.api_id if account.api_id is not None else self.config.api_id
@@ -147,10 +150,11 @@ class AccountManager:
await self.stop_all()
raise RuntimeError("No accounts were started successfully")
if self.ai_service is not None:
await self.ai_service.initialize()
try:
if self.ai_service is not None:
await self.ai_service.initialize()
await self.github_webhook_server.start()
await idle()
finally:
await self.github_webhook_server.stop()
await self.stop_all()