Skip to content

Commit

Permalink
🎨 添加了许多提示
Browse files Browse the repository at this point in the history
  • Loading branch information
wiseCirno committed Dec 3, 2024
1 parent f4662e2 commit 30549f5
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/Environment.py → src/utils/env.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
import os

from src.utils.Logger import logger
from .logger import logger


class EnvironmentReader:
def __init__(self):
# see https://core.telegram.org/bots/api#authorizing-your-bot
self.BOT_TOKEN = os.getenv('BOT_TOKEN', None)
self.CHAT_ANYWHERE_KEY = os.getenv('CHAT_ANYWHERE_KEY', None)
# you can get from this bot https://t.me/userinfobot
self.MY_USER_ID = int(os.getenv('MY_USER_ID', -1))
# see https://buyca.tech/ or https://api.chatanywhere.org/v1/oauth/free/render
self.CHAT_ANYWHERE_KEY = os.getenv('CHAT_ANYWHERE_KEY', None)
# support format like 'http://[host]:[port]', 'socks5://[host]:[port]'
self.PROXY = os.getenv('PROXY', None)
# see https://github.com/ymyuuu/Cloudflare-Workers-Proxy
self.CF_WORKER_PROXY = os.getenv('CF_WORKER_PROXY', None)
# you can not set this number too high, or you will be banned by image host services
self.TELEGRAPH_THREADS = int(os.getenv('TELEGRAPH_THREADS', 2))

def print_env(self):
logger.info(f"[Env]: Master user id: {self.MY_USER_ID}")
logger.info(f"[Env]: Telegraph threads: {self.TELEGRAPH_THREADS}")
logger.info(f"[Env]: Proxy: {self.PROXY}")
logger.info(f"[Env]: CloudFlare Worker Proxy: {self.CF_WORKER_PROXY}")
logger.debug(f"[Env]: Bot Token: {self.BOT_TOKEN}")
logger.debug(f"[Env]: Telegram user ID: {self.MY_USER_ID}")
logger.debug(f"[Env]: Telegraph download threads: {self.TELEGRAPH_THREADS}")

for key, value in [
("Chat Anywhere key", self.CHAT_ANYWHERE_KEY),
("Proxy", self.PROXY),
("CloudFlare Worker Proxy", self.CF_WORKER_PROXY),
]:
if value:
logger.debug(f"[Env] (str): {key}: '{value}'")

def print_attribute(self, attribute_name):
if hasattr(self, attribute_name):
Expand Down

0 comments on commit 30549f5

Please sign in to comment.