jack 11 hónapja
szülő
commit
4e425a68ca
2 módosított fájl, 7 hozzáadás és 6 törlés
  1. 6 5
      main.py
  2. 1 1
      send_matrix.py

+ 6 - 5
main.py

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

+ 1 - 1
send_matrix.py

@@ -25,7 +25,7 @@ class MatrixBot:
             except Exception as e:
                 print(e)
                 api = MatrixHttpApi(self.base_url, token=self.token)
-                api.send_message(self.to, e)
+                api.send_message(self.to, str(e))
 
         else:
             print("Bot is not logged in. Please login first.")