Something went wrong. Try again.
CLI tools and operational extensions for the void architecture on ATProtocol.
Something went wrong. Try again.
1.3 kB · 36 lines
Python
at commit fe774bdf
12345678910111213141516171819202122232425262728293031323334353637"""Core client initialization and environment loading."""import osimport sysfrom dotenv import load_dotenvfrom atproto import Client
def load_credentials(): """Loads credentials from .env in the project root, explicitly overriding the system environment variables.""" # Look for .env in the current working directory, or walk up env_path = os.path.join(os.getcwd(), '.env') if os.path.exists(env_path): load_dotenv(env_path, override=True) else: # Fallback to home/void/.env if working somewhere else home_env = os.path.expanduser('~/void/.env') if os.path.exists(home_env): load_dotenv(home_env, override=True)
username = os.getenv("BSKY_USERNAME") password = os.getenv("BSKY_PASSWORD") pds_uri = os.getenv("PDS_URI", "https://bsky.social")
if not username or not password: print("Error: BSKY_USERNAME and BSKY_PASSWORD environment variables must be set.", file=sys.stderr) sys.exit(1)
return username, password, pds_uri
def get_client() -> Client: """Returns an authenticated atproto Client.""" username, password, pds_uri = load_credentials() client = Client(base_url=pds_uri) client.login(username, password) return client