This commit is contained in:
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "jwebot-official-extensions"
|
||||
version = "0.6.11a0+1015"
|
||||
version = "1.0.0b1+1016"
|
||||
description = "Reviewed local command adapters and broker implementation for JWeBot"
|
||||
requires-python = ">=3.9"
|
||||
dependencies = [
|
||||
"jwebot-sdk==0.6.11a0+1015",
|
||||
"jwebot-sdk==1.0.0b1+1016",
|
||||
]
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
|
||||
@@ -90,4 +90,4 @@ __all__ = [
|
||||
"render_feature_list",
|
||||
]
|
||||
|
||||
__version__ = "0.6.11a0+1015"
|
||||
__version__ = "1.0.0b1+1016"
|
||||
|
||||
+65
-1
@@ -11,6 +11,7 @@ import subprocess
|
||||
import time
|
||||
from collections import Counter
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
@@ -26,6 +27,7 @@ BEIJING_TIMEZONE = ZoneInfo("Asia/Shanghai")
|
||||
DICE_PATTERN = re.compile(r"^(?:(\d{1,2})[dD](\d{1,3}))?$")
|
||||
RANDOM_NUMBER_PATTERN = re.compile(r"^(-?\d{1,6})\s+(-?\d{1,6})$")
|
||||
MULTI_REPLY_MARKER = "\x1eJWEBOT_MULTI_REPLY_V1\x1e"
|
||||
CHANGELOG_HEADING = re.compile(r"^##\s+(.+?)(?:\s+-\s+(\d{4}-\d{2}-\d{2}))?\s*$")
|
||||
|
||||
|
||||
class LocalCommandError(RuntimeError):
|
||||
@@ -401,13 +403,75 @@ class LocalCommandEngine:
|
||||
return "unknown"
|
||||
return str(getattr(module, "__version__", "unknown"))
|
||||
|
||||
@staticmethod
|
||||
def changelog_candidates() -> list[Path]:
|
||||
candidates: list[Path] = []
|
||||
module_path = Path(__file__).resolve()
|
||||
for parent in (module_path.parent, *module_path.parents):
|
||||
candidates.append(parent / "CHANGELOG.md")
|
||||
candidates.append(Path.cwd() / "CHANGELOG.md")
|
||||
seen: set[Path] = set()
|
||||
unique: list[Path] = []
|
||||
for candidate in candidates:
|
||||
if candidate in seen:
|
||||
continue
|
||||
seen.add(candidate)
|
||||
unique.append(candidate)
|
||||
return unique
|
||||
|
||||
@classmethod
|
||||
def latest_changelog(cls) -> dict[str, str]:
|
||||
for path in cls.changelog_candidates():
|
||||
if not path.is_file():
|
||||
continue
|
||||
text = path.read_text(encoding="utf-8")
|
||||
lines = text.splitlines()
|
||||
for index, line in enumerate(lines):
|
||||
match = CHANGELOG_HEADING.match(line)
|
||||
if not match:
|
||||
continue
|
||||
version = match.group(1).strip()
|
||||
updated_at = (match.group(2) or "").strip()
|
||||
bullet_parts: list[str] = []
|
||||
collecting = False
|
||||
for item in lines[index + 1 :]:
|
||||
if item.startswith("## "):
|
||||
break
|
||||
if item.startswith("- "):
|
||||
if collecting:
|
||||
break
|
||||
collecting = True
|
||||
bullet_parts.append(item[2:].strip())
|
||||
continue
|
||||
if collecting:
|
||||
if item.startswith(" "):
|
||||
bullet_parts.append(item.strip())
|
||||
continue
|
||||
if not item.strip():
|
||||
break
|
||||
summary = normalize_text(" ".join(bullet_parts))
|
||||
return {
|
||||
"version": version,
|
||||
"updated_at": updated_at or "unknown",
|
||||
"summary": summary or "暂无更新摘要",
|
||||
}
|
||||
return {
|
||||
"version": "unknown",
|
||||
"updated_at": "unknown",
|
||||
"summary": "未找到 CHANGELOG.md",
|
||||
}
|
||||
|
||||
def jwebot_version(self) -> str:
|
||||
changelog = self.latest_changelog()
|
||||
return (
|
||||
"JWeBot 版本:"
|
||||
f"kernel {self.package_version('jwebot_kernel')},"
|
||||
f"sdk {self.package_version('jwebot_sdk')},"
|
||||
"official "
|
||||
f"{self.package_version('jwebot_official_extensions')}"
|
||||
f"{self.package_version('jwebot_official_extensions')}\n"
|
||||
f"最新版本:{changelog['version']}\n"
|
||||
f"更新时间:{changelog['updated_at']}\n"
|
||||
f"更新摘要:{changelog['summary']}"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user