Use wonderwords for shell names

This commit is contained in:
lda
2026-08-30 01:53:53 +07:00 Verified
parent d4d05d12cf
commit cf0ec7b403
4 changed files with 38 additions and 4 deletions
+6 -4
View File
@@ -2,20 +2,22 @@ import contextlib
import io
import json
from dataclasses import asdict
from random import choice
from uuid import uuid4
from wonderwords import RandomWord
from .models import CallResponse
from .shell import Shell
_ADJECTIVES = ("bright", "calm", "curious", "quiet", "swift")
_NOUNS = ("otter", "comet", "raven", "panda", "badger")
_WORD_GENERATOR = RandomWord()
def generate_good_names() -> str:
"""Generate a readable, collision-resistant shell name."""
return f"{choice(_ADJECTIVES)}-{choice(_NOUNS)}-{uuid4().hex[:4]}"
adjective = _WORD_GENERATOR.word(include_parts_of_speech=["adjectives"])
noun = _WORD_GENERATOR.word(include_parts_of_speech=["nouns"])
return f"{adjective}-{noun}-{uuid4().hex[:4]}"
class App: