mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Enhance Roblox API integration and refactor CLI commands
- Updated the `clap` dependency in `Cargo.toml` to include the "env" feature for improved command-line argument handling. - Introduced a new `roblox_api` module to encapsulate Roblox API interactions, including authentication and asset downloading. - Refactored the `CloneCommand` and `StudioCommand` to utilize the new `roblox_api` functions for fetching experience names and universe IDs, enhancing code clarity and reducing duplication. - Removed obsolete functions related to Roblox API calls from the CLI commands, streamlining the codebase. - Added error handling for authentication failures, ensuring better user feedback when required credentials are missing. These changes aim to improve the overall structure and functionality of the CLI while enhancing the integration with the Roblox API.
This commit is contained in:
parent
fb46515913
commit
9934094dbc
22 changed files with 2427 additions and 161 deletions
67
tools/atlas-daemon/atlas_daemon/__main__.py
Normal file
67
tools/atlas-daemon/atlas_daemon/__main__.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import click
|
||||
|
||||
from .bot import AtlasDaemonBot
|
||||
from .config import Config
|
||||
from .db import Database
|
||||
from .security import init_encryption
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--discord-token", envvar="ATLAS_DAEMON_DISCORD_TOKEN", default="", help="Discord bot token")
|
||||
@click.option("--anthropic-key", envvar="ATLAS_DAEMON_ANTHROPIC_KEY", default="", help="Anthropic API key")
|
||||
@click.option("--data-dir", envvar="ATLAS_DAEMON_DATA_DIR", default="./atlas-daemon-data", help="Data directory")
|
||||
@click.option("--encryption-key", envvar="ATLAS_DAEMON_ENCRYPTION_KEY", default="", help="Fernet encryption key")
|
||||
@click.option("--sync-interval", envvar="ATLAS_DAEMON_SYNC_INTERVAL", default=300, type=int, help="Sync interval (seconds)")
|
||||
@click.option("--atlas-binary", envvar="ATLAS_DAEMON_ATLAS_BINARY", default="atlas", help="Path to atlas binary")
|
||||
def main(
|
||||
discord_token: str,
|
||||
anthropic_key: str,
|
||||
data_dir: str,
|
||||
encryption_key: str,
|
||||
sync_interval: int,
|
||||
atlas_binary: str,
|
||||
) -> None:
|
||||
"""Atlas Daemon - Automated Roblox Code Review Bot"""
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s [%(name)s] %(levelname)s: %(message)s",
|
||||
datefmt="%Y-%m-%d %H:%M:%S",
|
||||
)
|
||||
|
||||
if not discord_token:
|
||||
click.echo("Error: Discord token is required (--discord-token or ATLAS_DAEMON_DISCORD_TOKEN)", err=True)
|
||||
sys.exit(1)
|
||||
if not anthropic_key:
|
||||
click.echo("Error: Anthropic key is required (--anthropic-key or ATLAS_DAEMON_ANTHROPIC_KEY)", err=True)
|
||||
sys.exit(1)
|
||||
|
||||
config = Config.from_env(
|
||||
discord_token=discord_token,
|
||||
anthropic_key=anthropic_key,
|
||||
data_dir=data_dir,
|
||||
encryption_key=encryption_key,
|
||||
sync_interval=sync_interval,
|
||||
atlas_binary=atlas_binary,
|
||||
)
|
||||
|
||||
config.data_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
init_encryption(config.encryption_key)
|
||||
|
||||
db = Database(config.data_dir / "atlas-daemon.db")
|
||||
|
||||
import anthropic as anthropic_mod
|
||||
|
||||
claude = anthropic_mod.AsyncAnthropic(api_key=config.anthropic_key)
|
||||
|
||||
bot = AtlasDaemonBot(config, db, claude)
|
||||
bot.run(config.discord_token)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue