if ($deleteAll || $isPv || $isMine) { $toDelete[] = $m['id']; if (count($toDelete) >= $n) { break; } } } } $deletedCount = 0; if ($toDelete) { $chunks = array_chunk($toDelete, 50); foreach ($chunks as $chunk) { try { $this->messages->deleteMessages(id: $chunk, revoke: true); $this->markSelfDeleted($chunk); $deletedCount += count($chunk); } catch (\Throwable $eChunk) { $this->logger('bulk delete chunk error: ' . $eChunk->getMessage()); } } } } catch (\Throwable $e) { $this->logger('bulk delete error: ' . $e->getMessage()); $msg = $e->getMessage(); if (preg_match('/FLOOD_WAIT_(\d+)/', $msg, $mm)) { $wait = (int) $mm[1]; try { $this->logger("Telegram flood wait limit: {$wait}s"); } catch (\Throwable $e2) {} } } try { $this->messages->deleteMessages(id: [$message->id], revoke: true); $this->markSelfDeleted([$message->id]); } catch (\Throwable $e) {} if ($deletedCount > 0) { $this->sendMsg($message->chatId, "🗑 تعداد {$deletedCount} پیام با موفقیت پاک شد.", $this->topicReplyTo($message)); } else { $this->sendMsg($message->chatId, "⚠️ هیچ پیامی برای حذف پیدا نشد.", $this->topicReplyTo($message)); } return; } if ($cmd === 'تگ') { try { $chat = $this->getPwrChat($message->chatId, true);