private function cfg(): array { return SB_CONFIG; } // این متد یک‌بار موقع شروع صدا زده میشه public function onStart(): void { $ownerId = $this->getOwnerId(); $this->logger("✅ سلف بات (PHP/MadelineProto) برای کاربر {$ownerId} روشن شد."); $this->clockLoop = new PeriodicLoop($this->tickClocksLoop(...), 'clock-tick', 3.0); $this->clockLoop->start(); $this->actionLoop = new PeriodicLoop($this->tickActionLoop(...), 'action-tick', 4.0); $this->actionLoop->start(); // پاکسازی روزانه‌ی دیتابیس کش پیام‌ها، تا بی‌نهایت بزرگ نشه $this->cleanupLoop = new PeriodicLoop($this->tickCleanupLoop(...), 'cleanup-tick', 3600.0); $this->cleanupLoop->start(); } private function tickCleanupLoop(): bool { try { Store::cleanupOld(3); // فقط ۳ روز اخیر رو نگه دار } catch (\Throwable $e) { $this->logger('cleanup error: ' . $e->getMessage()); } return false; }