fix(debate): idle-state 처리 + slug 탐색 — AG 대기 규칙, list-debates 커맨드, handler 시그널 개선
This commit is contained in:
@@ -66,6 +66,28 @@ async def _query(query: str, variables: dict = None) -> dict:
|
||||
return data.get("data", {})
|
||||
|
||||
|
||||
async def list_debates() -> list[str]:
|
||||
"""Wiki.js에서 debates/ 하위의 활성 토론 slug 목록을 조회."""
|
||||
query = """
|
||||
query {
|
||||
pages { list(orderBy: UPDATED, orderByDirection: DESC) {
|
||||
id, path, updatedAt
|
||||
}}
|
||||
}
|
||||
"""
|
||||
data = await _query(query)
|
||||
pages = data.get("pages", {}).get("list", [])
|
||||
slugs = set()
|
||||
for p in pages:
|
||||
path = p.get("path", "")
|
||||
# debates/{slug}/input-* 형태의 페이지에서 slug 추출
|
||||
if path.startswith("debates/") and "/input-" in path:
|
||||
parts = path.split("/")
|
||||
if len(parts) >= 3:
|
||||
slugs.add(parts[1])
|
||||
return sorted(slugs)
|
||||
|
||||
|
||||
async def read_page(path: str) -> str:
|
||||
"""경로로 페이지 읽기 (singleByPath)."""
|
||||
query = """
|
||||
@@ -143,6 +165,18 @@ async def main():
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
||||
|
||||
args = sys.argv[1:]
|
||||
|
||||
# list-debates 커맨드는 인수 불필요
|
||||
if args and args[0] == "list-debates":
|
||||
slugs = await list_debates()
|
||||
if slugs:
|
||||
print("활성 토론 목록:")
|
||||
for s in slugs:
|
||||
print(f" - {s}")
|
||||
else:
|
||||
print("진행 중인 토론이 없습니다.")
|
||||
return
|
||||
|
||||
if len(args) < 2:
|
||||
print(__doc__)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user