chore: remove RELEASE_NOTES.md and generate change notes dynamically

This commit is contained in:
mamad
2026-08-28 23:33:55 +03:30
parent fd1e2abdba
commit a554af27c8
3 changed files with 13 additions and 54 deletions
+13 -29
View File
@@ -1601,38 +1601,22 @@ class AdminBotService:
await event.reply(help_text, parse_mode="html", buttons=menu)
def get_latest_change_notes(self) -> str:
"""Return the formatted change notes in Persian from RELEASE_NOTES.md."""
notes_file = os.path.join(os.path.dirname(os.path.dirname(__file__)), "RELEASE_NOTES.md")
if os.path.exists(notes_file):
try:
with open(notes_file, "r", encoding="utf-8") as f:
content = f.read().strip()
if content:
return content
except Exception as e:
logger.debug(f"Error reading RELEASE_NOTES.md: {e}")
"""Return the formatted change notes dynamically from the latest git commit."""
try:
res = subprocess.run(
["git", "log", "-1", "--pretty=format:🔹 <b>%s</b>%n%b"],
cwd=os.path.dirname(os.path.dirname(__file__)),
capture_output=True,
text=True,
timeout=5
)
if res.returncode == 0 and res.stdout.strip():
return f"📢 <b>آخرین تغییرات سیستم (Release Notes):</b>\n\n{res.stdout.strip()}"
except Exception as e:
logger.debug(f"Error reading git log for change notes: {e}")
return "📢 <b>گزارش تغییرات سیستم (Release Notes):</b>\nسیستم با آخرین به‌روزرسانی‌ها در حال اجرا است."
async def broadcast_change_notes(self):
"""Send latest change notes to admins and review channel if they are new."""
import hashlib
notes = self.get_latest_change_notes()
current_hash = hashlib.sha256(notes.encode("utf-8")).hexdigest()
last_hash = await self.repo.get_setting("last_broadcast_release_hash")
if last_hash == current_hash:
logger.info("Release notes have not changed since last broadcast. Skipping automatic broadcast.")
return
logger.info(f"Broadcasting new release notes directly to admin DMs (hash: {current_hash[:8]})...")
await self.notify_admins(notes, include_review_channel=False)
await self.repo.set_setting(
"last_broadcast_release_hash",
current_hash,
description="Hash of last broadcast release notes"
)
# --- Step-by-Step Parameter & Text Input Message Handler ---
@self.client.on(events.NewMessage)