Files
myfirstprogram/config.py
T

75 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import os
from pathlib import Path
from dotenv import load_dotenv
from typing import Dict
load_dotenv()
def _env_bool(name: str, default: bool = False) -> bool:
raw = os.getenv(name)
if raw is None:
return default
return raw.strip().lower() in ("1", "true", "yes", "on")
class Config:
# API
API_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
Token = os.getenv("ACCESS_TOKEN")
DEEPGRAM_API_KEY = os.getenv("DEEPGRAM_API_KEY")
DEEPGRAM_AGENT_URL = "https://api.deepgram.com/v1/agent/think"
DEEPGRAM_TTS_URL = "https://api.deepgram.com/v1/speak?"
# 5575756416
BAN = [1]
if not API_TOKEN:
raise ValueError("❌ TELEGRAM_BOT_TOKEN не найден в переменных окружения!")
# Admins (user_id: уровень)
ADMINS: Dict[int, int] = {850906163: 0, 6394047531: 4, 1345058877: 3}
Names: Dict[int, str] = {850906163: "Ляпич", 6394047531: "Прокопович", 1345058877: "Сом"}
# Chats
CHAT_IDS = [-1003038389942]
GROUP_CHATS: Dict[str, int] = {
"30тс": -1003038389942,
"5Cа": 7571257031,
}
# Settings
ANTISPAM_DELAY = 20
WATCHER_INTERVAL_SEC = 600
WATCHER_RANDOM_DELAY_MIN = 1
WATCHER_RANDOM_DELAY_MAX = 120
SCHEDULE_DRIVE_FOLDER_ID = os.getenv(
"SCHEDULE_DRIVE_FOLDER_ID", "1WhUFHGkS4qC_e84KRArF4ooXHJr8mL5T"
)
# Отключение логов и хранения (см. .env.example)
# DISABLE_PERSISTENCE=1 — выключает и логи, и все БД/файлы сразу
_NO_PERSISTENCE = _env_bool("DISABLE_PERSISTENCE")
DISABLE_LOGGING = (
_env_bool("DISABLE_LOGGING")
if os.getenv("DISABLE_LOGGING") is not None
else _NO_PERSISTENCE
)
DISABLE_STORAGE = (
_env_bool("DISABLE_STORAGE")
if os.getenv("DISABLE_STORAGE") is not None
else _NO_PERSISTENCE
)
# Пути
LOG_FILE = Path("storage/log/bot.log")
DAYS_TO_DB_PATH = Path("addons/x_days_to/days_to_new_year.db")
if __name__ == "__main__":
a = Config()
print(a.API_TOKEN)
print(a.ADMINS)