mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 17:47:06 +08:00
- Move logo and print_logo to new astrbot/cli/banner.py module to avoid circular imports - Add is_interactive() helper to detect TTY - Show ASCII logo in run/init commands only in interactive mode - Show WeChat QR code ASCII art only in interactive mode; non-interactive mode shows just the QR link
30 lines
939 B
Python
30 lines
939 B
Python
"""ASCII logo and interactive mode utilities for CLI"""
|
|
|
|
import sys
|
|
|
|
|
|
logo_tmpl = r"""
|
|
___ _______.___________..______ .______ ______ .___________.
|
|
/ \ / | || _ \ | _ \ / __ \ | |
|
|
/ ^ \ | (----`---| |----`| |_) | | |_) | | | | | `---| |----`
|
|
/ /_\ \ \ \ | | | / | _ < | | | | | |
|
|
/ _____ \ .----) | | | | |\ \----.| |_) | | `--' | | |
|
|
/__/ \__\ |_______/ |__| | _| `._____||______/ \______/ |__|
|
|
"""
|
|
|
|
|
|
def is_interactive() -> bool:
|
|
"""Check if stdout is connected to a TTY (interactive terminal)"""
|
|
try:
|
|
return sys.stdout.isatty()
|
|
except Exception:
|
|
return False
|
|
|
|
|
|
def print_logo() -> None:
|
|
"""Print ASCII logo if in interactive mode"""
|
|
import click
|
|
|
|
if is_interactive():
|
|
click.echo(logo_tmpl)
|