-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathr.py
More file actions
115 lines (88 loc) · 4.03 KB
/
r.py
File metadata and controls
115 lines (88 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import os
from dotenv import load_dotenv
load_dotenv()
# 定义更新 .env 文件的函数
def update_env_variable(key, value):
# 读取现有的 .env 文件
with open('.env', 'r') as file:
lines = file.readlines()
# 查找并更新变量
updated = False
for i, line in enumerate(lines):
if line.startswith(f"{key}="):
lines[i] = f"{key}={value}\n"
updated = True
break
# 如果没有找到变量,则添加它
if not updated:
lines.append(f"{key}={value}\n")
# 将更新后的内容写回 .env 文件
with open('.env', 'w') as file:
file.writelines(lines)
# 更新环境变量,使其生效
os.environ[key] = value
appid = os.getenv("QQBOT_APP_ID")
if appid is None:
raise Exception('Missing "QQBOT_APP_ID" environment variable for your bot AppID')
secret = os.getenv("QQBOT_APP_SECRET")
if secret is None:
raise Exception('Missing "QQBOT_APP_SECRET" environment variable for your AppSecret')
weather_api_token = os.getenv("WEATHER_API_TOKEN")
if weather_api_token is None:
raise Exception('Missing "WEATHER_API_TOKEN" environment variable for your AppSecret')
api_app_id = os.getenv("API_APP_ID")
if api_app_id is None:
raise Exception('Missing "API_APP_ID" environment variable for your AppSecret')
api_app_secret = os.getenv("API_APP_SECRET")
if api_app_secret is None:
raise Exception('Missing "API_APP_SECRET" environment variable for your AppSecret')
mc_servers = os.getenv("MC_SERVERS")
if mc_servers is None:
raise Exception('Missing "MC_SERVERS" environment variable for your bot MC_SERVERS')
mc_mcsrvstat_servers = os.getenv("MC_MCSRVSTAT_SERVERS", "")
baidu_url = os.getenv("Baidu_URL")
if baidu_url is None:
raise Exception('Missing "baidu_url" environment variable for your bot baidu_url')
baidu_api_key = os.getenv("Baidu_API_Key")
if baidu_api_key is None:
raise Exception('Missing "Baidu_API_Key" environment variable for your bot Baidu_API_Key')
ecust_api_key = os.getenv("ECUST_API_Key")
if ecust_api_key is None:
raise Exception('Missing "ECUST_API_Key" environment variable for your bot ECUST_API_Key')
ecust_url = os.getenv("ECUST_URL")
if ecust_url is None:
raise Exception('Missing "ECUST_URL" environment variable for your bot ECUST_URL')
ecust_model = os.getenv("ECUST_MODEL")
if ecust_model is None:
raise Exception('Missing "ECUST_MODEL" environment variable for your bot ecust_model')
clawdbot_url = os.getenv("CLAWDBOT_URL")
if clawdbot_url is None:
raise Exception('Missing "CLAWDBOT_URL" environment variable for your bot CLAWDBOT_URL')
clawdbot_api_key = os.getenv("CLAWDBOT_API_Key")
if clawdbot_api_key is None:
raise Exception('Missing "CLAWDBOT_API_Key" environment variable for your bot CLAWDBOT_API_Key')
tjit_key= os.getenv("TJIT_KEY")
if tjit_key is None:
raise Exception('Missing "TJIT_KEY" environment variable for your bot TJIT_KEY')
mc_rcon_password= os.getenv("MC_KEY")
if mc_rcon_password is None:
raise Exception('Missing "MC_KEY" environment variable for your bot MC_KEY')
mc_server = os.getenv("MC_SERVER")
if mc_server is None:
raise Exception('Missing "MC_SERVER" environment variable for your bot MC_SERVER')
mc_rcon_port = os.getenv("MC_RCON_PORT")
if mc_rcon_port is None:
raise Exception('Missing "MC_RCON_PORT" environment variable for your bot MC_RCON_PORT')
# 三角洲行动API配置
deltaforce_api_token = os.getenv("DELTAFORCE_API_TOKEN")
if deltaforce_api_token is None:
raise Exception('Missing "DELTAFORCE_API_TOKEN" environment variable for Delta Force API')
# 查询空教室API配置
class_api_token = os.getenv("CLASS_API_KEY")
if class_api_token is None:
raise Exception('Missing "CLASS_API_KEY" environment variable for CLASS_API_KEY')
# AI功能开关配置
ai_group_enabled = os.getenv("AI_GROUP_ENABLED", "false").lower() == "true"
ai_direct_enabled = os.getenv("AI_DIRECT_ENABLED", "false").lower() == "true"
# 春节期间运势增强功能开关
spring_festival_enabled = os.getenv("SPRING_FESTIVAL_ENABLED", "false").lower() == "true"