|
@@ -14,13 +14,13 @@ key = 'web3'
|
|
|
|
|
|
|
|
|
|
|
|
|
class AINEWS:
|
|
class AINEWS:
|
|
|
- def create_config_if_not_exists():
|
|
|
|
|
|
|
+ def create_config_if_not_exists(self):
|
|
|
# 获取当前文件的目录路径
|
|
# 获取当前文件的目录路径
|
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# 构建 config.json 文件的完整路径
|
|
# 构建 config.json 文件的完整路径
|
|
|
config_path = os.path.join(current_dir, 'config.json')
|
|
config_path = os.path.join(current_dir, 'config.json')
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# 检查 config.json 文件是否存在
|
|
# 检查 config.json 文件是否存在
|
|
|
if not os.path.exists(config_path):
|
|
if not os.path.exists(config_path):
|
|
|
# 如果不存在,创建并写入默认的 JSON 数据
|
|
# 如果不存在,创建并写入默认的 JSON 数据
|
|
@@ -31,12 +31,13 @@ class AINEWS:
|
|
|
"role": ""
|
|
"role": ""
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# 写入 JSON 数据到 config.json 文件
|
|
# 写入 JSON 数据到 config.json 文件
|
|
|
with open(config_path, 'w', encoding='utf-8') as f:
|
|
with open(config_path, 'w', encoding='utf-8') as f:
|
|
|
json.dump(default_config, f, indent=4)
|
|
json.dump(default_config, f, indent=4)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
print(f"Created {config_path} with default configuration.")
|
|
print(f"Created {config_path} with default configuration.")
|
|
|
|
|
+
|
|
|
def save_to_txt(self, url_to_text):
|
|
def save_to_txt(self, url_to_text):
|
|
|
current_file_path = os.path.dirname(__file__)
|
|
current_file_path = os.path.dirname(__file__)
|
|
|
save_file_path = os.path.join(current_file_path, 'save_txt')
|
|
save_file_path = os.path.join(current_file_path, 'save_txt')
|