soulsync 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.json.example +1 -1
- package/index.js +46 -21
- package/package.json +1 -1
- package/src/client.py +31 -8
- package/src/interactive_auth.py +1 -1
- package/src/main.py +209 -3
- package/src/main_fixed.py +1 -1
package/config.json.example
CHANGED
package/index.js
CHANGED
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
const { spawn } = require('child_process');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
+
let pythonProcess = null;
|
|
5
|
+
|
|
4
6
|
// 函数形式导出(推荐)
|
|
5
7
|
module.exports = function register(api) {
|
|
6
8
|
console.log('[SoulSync] Registering plugin...');
|
|
7
9
|
|
|
10
|
+
// 自动启动 Python 服务
|
|
11
|
+
function startPythonService() {
|
|
12
|
+
const pluginDir = path.dirname(__filename);
|
|
13
|
+
const pythonScript = path.join(pluginDir, 'src', 'main.py');
|
|
14
|
+
const pythonPath = process.env.PYTHON_PATH || 'python3';
|
|
15
|
+
|
|
16
|
+
console.log('[SoulSync] Auto-starting Python service...');
|
|
17
|
+
|
|
18
|
+
pythonProcess = spawn(pythonPath, [pythonScript], {
|
|
19
|
+
cwd: pluginDir,
|
|
20
|
+
env: {
|
|
21
|
+
...process.env,
|
|
22
|
+
OPENCLAW_PLUGIN: 'true',
|
|
23
|
+
PLUGIN_DIR: pluginDir
|
|
24
|
+
},
|
|
25
|
+
stdio: 'inherit'
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
pythonProcess.on('close', (code) => {
|
|
29
|
+
console.log(`[SoulSync] Python process exited with code ${code}`);
|
|
30
|
+
pythonProcess = null;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
pythonProcess.on('error', (err) => {
|
|
34
|
+
console.error(`[SoulSync] Failed to start Python process: ${err}`);
|
|
35
|
+
pythonProcess = null;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
8
39
|
// 注册CLI命令:启动 SoulSync
|
|
9
40
|
api.registerCli(
|
|
10
41
|
({ program }) => {
|
|
@@ -12,25 +43,11 @@ module.exports = function register(api) {
|
|
|
12
43
|
.command('soulsync:start')
|
|
13
44
|
.description('启动 SoulSync 同步服务')
|
|
14
45
|
.action(() => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const pythonProcess = spawn(pythonPath, [pythonScript], {
|
|
22
|
-
cwd: pluginDir,
|
|
23
|
-
env: {
|
|
24
|
-
...process.env,
|
|
25
|
-
OPENCLAW_PLUGIN: 'true',
|
|
26
|
-
PLUGIN_DIR: pluginDir
|
|
27
|
-
},
|
|
28
|
-
stdio: 'inherit'
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
pythonProcess.on('close', (code) => {
|
|
32
|
-
console.log(`[SoulSync] Python process exited with code ${code}`);
|
|
33
|
-
});
|
|
46
|
+
if (pythonProcess) {
|
|
47
|
+
console.log('[SoulSync] Service already running');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
startPythonService();
|
|
34
51
|
});
|
|
35
52
|
},
|
|
36
53
|
{ commands: ['soulsync:start'] }
|
|
@@ -43,12 +60,20 @@ module.exports = function register(api) {
|
|
|
43
60
|
.command('soulsync:stop')
|
|
44
61
|
.description('停止 SoulSync 同步服务')
|
|
45
62
|
.action(() => {
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
if (pythonProcess) {
|
|
64
|
+
console.log('[SoulSync] Stopping Python service...');
|
|
65
|
+
pythonProcess.kill();
|
|
66
|
+
pythonProcess = null;
|
|
67
|
+
} else {
|
|
68
|
+
console.log('[SoulSync] Service not running');
|
|
69
|
+
}
|
|
48
70
|
});
|
|
49
71
|
},
|
|
50
72
|
{ commands: ['soulsync:stop'] }
|
|
51
73
|
);
|
|
52
74
|
|
|
75
|
+
// 自动启动服务
|
|
76
|
+
startPythonService();
|
|
77
|
+
|
|
53
78
|
console.log('[SoulSync] Plugin registered successfully');
|
|
54
79
|
};
|
package/package.json
CHANGED
package/src/client.py
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
|
+
import ssl
|
|
3
4
|
import uuid
|
|
4
5
|
import requests
|
|
5
6
|
import websocket
|
|
7
|
+
from requests.adapters import HTTPAdapter
|
|
8
|
+
from urllib3.poolmanager import PoolManager
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TLSAdapter(HTTPAdapter):
|
|
12
|
+
"""使用兼容 Python 3.13 的 SSL 适配器"""
|
|
13
|
+
def init_poolmanager(self, *args, **kwargs):
|
|
14
|
+
# 使用 create_default_context() 而不是 SSLContext(PROTOCOL_TLS_CLIENT)
|
|
15
|
+
# 这在 Python 3.13 + Windows 上更稳定
|
|
16
|
+
ctx = ssl.create_default_context()
|
|
17
|
+
# 可选:设置最低 TLS 版本为 1.2
|
|
18
|
+
ctx.minimum_version = ssl.TLSVersion.TLSv1_2
|
|
19
|
+
kwargs['ssl_context'] = ctx
|
|
20
|
+
return super().init_poolmanager(*args, **kwargs)
|
|
6
21
|
|
|
7
22
|
|
|
8
23
|
class OpenClawClient:
|
|
@@ -16,6 +31,10 @@ class OpenClawClient:
|
|
|
16
31
|
self.device_id = self._load_or_generate_device_id()
|
|
17
32
|
self.ws = None
|
|
18
33
|
self.ws_thread = None
|
|
34
|
+
|
|
35
|
+
# 创建使用 TLS 1.2 的 session
|
|
36
|
+
self.session = requests.Session()
|
|
37
|
+
self.session.mount('https://', TLSAdapter())
|
|
19
38
|
|
|
20
39
|
def _load_or_generate_device_id(self) -> str:
|
|
21
40
|
"""加载或生成设备ID"""
|
|
@@ -95,7 +114,7 @@ class OpenClawClient:
|
|
|
95
114
|
'password': password
|
|
96
115
|
}
|
|
97
116
|
|
|
98
|
-
response =
|
|
117
|
+
response = self.session.post(url, json=data, headers={'Content-Type': 'application/json'})
|
|
99
118
|
|
|
100
119
|
if response.status_code == 200:
|
|
101
120
|
result = response.json()
|
|
@@ -105,8 +124,12 @@ class OpenClawClient:
|
|
|
105
124
|
print(f"Logged in: {email}")
|
|
106
125
|
return result
|
|
107
126
|
elif response.status_code == 401:
|
|
108
|
-
# Login failed
|
|
127
|
+
# Login failed
|
|
109
128
|
raise Exception(f"Invalid email or password / 邮箱或密码错误")
|
|
129
|
+
elif response.status_code == 429:
|
|
130
|
+
# Rate limited
|
|
131
|
+
error = response.json().get('error', 'Too many attempts')
|
|
132
|
+
raise Exception(f"429: {error}")
|
|
110
133
|
else:
|
|
111
134
|
error = response.json().get('error', 'Unknown error')
|
|
112
135
|
raise Exception(f"Authentication failed: {error}")
|
|
@@ -123,7 +146,7 @@ class OpenClawClient:
|
|
|
123
146
|
url = f"{self.cloud_url}/api/memories"
|
|
124
147
|
data = {'content': content}
|
|
125
148
|
|
|
126
|
-
response =
|
|
149
|
+
response = self.session.post(url, json=data, headers=self._get_headers())
|
|
127
150
|
|
|
128
151
|
if response.status_code == 200:
|
|
129
152
|
return response.json()
|
|
@@ -142,7 +165,7 @@ class OpenClawClient:
|
|
|
142
165
|
"""
|
|
143
166
|
url = f"{self.cloud_url}/api/memories"
|
|
144
167
|
|
|
145
|
-
response =
|
|
168
|
+
response = self.session.get(url, headers=self._get_headers())
|
|
146
169
|
|
|
147
170
|
if response.status_code == 200:
|
|
148
171
|
return response.json()
|
|
@@ -160,7 +183,7 @@ class OpenClawClient:
|
|
|
160
183
|
"""
|
|
161
184
|
url = f"{self.cloud_url}/api/memories/profile"
|
|
162
185
|
|
|
163
|
-
response =
|
|
186
|
+
response = self.session.get(url, headers=self._get_headers())
|
|
164
187
|
|
|
165
188
|
if response.status_code == 200:
|
|
166
189
|
return response.json()
|
|
@@ -231,7 +254,7 @@ class OpenClawClient:
|
|
|
231
254
|
url = f"{self.cloud_url}/api/auth/send-code"
|
|
232
255
|
data = {'email': email}
|
|
233
256
|
|
|
234
|
-
response =
|
|
257
|
+
response = self.session.post(url, json=data, headers={'Content-Type': 'application/json'})
|
|
235
258
|
|
|
236
259
|
if response.status_code == 200:
|
|
237
260
|
return response.json()
|
|
@@ -256,7 +279,7 @@ class OpenClawClient:
|
|
|
256
279
|
url = f"{self.cloud_url}/api/auth/register"
|
|
257
280
|
data = {'email': email, 'password': password, 'code': code}
|
|
258
281
|
|
|
259
|
-
response =
|
|
282
|
+
response = self.session.post(url, json=data, headers={'Content-Type': 'application/json'})
|
|
260
283
|
|
|
261
284
|
if response.status_code == 201:
|
|
262
285
|
result = response.json()
|
|
@@ -281,7 +304,7 @@ class OpenClawClient:
|
|
|
281
304
|
url = f"{self.cloud_url}/api/auth/login"
|
|
282
305
|
data = {'email': email, 'password': password}
|
|
283
306
|
|
|
284
|
-
response =
|
|
307
|
+
response = self.session.post(url, json=data, headers={'Content-Type': 'application/json'})
|
|
285
308
|
|
|
286
309
|
if response.status_code == 200:
|
|
287
310
|
result = response.json()
|
package/src/interactive_auth.py
CHANGED
|
@@ -248,7 +248,7 @@ def prompt_for_missing_config(client):
|
|
|
248
248
|
|
|
249
249
|
# 如果没有 cloud_url,设置默认值
|
|
250
250
|
if not cloud_url:
|
|
251
|
-
config['cloud_url'] = '
|
|
251
|
+
config['cloud_url'] = 'https://soulsync.work'
|
|
252
252
|
print(f"Using default server / 使用默认服务器: {config['cloud_url']}")
|
|
253
253
|
|
|
254
254
|
# 交互式登录/注册
|
package/src/main.py
CHANGED
|
@@ -7,6 +7,7 @@ import json
|
|
|
7
7
|
import os
|
|
8
8
|
import sys
|
|
9
9
|
import time
|
|
10
|
+
import getpass
|
|
10
11
|
|
|
11
12
|
# 获取插件根目录
|
|
12
13
|
PLUGIN_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
@@ -40,11 +41,18 @@ class SoulSyncPlugin:
|
|
|
40
41
|
def load_config(self):
|
|
41
42
|
"""加载配置文件"""
|
|
42
43
|
config_path = os.path.normpath(os.path.join(PLUGIN_DIR, 'config.json'))
|
|
44
|
+
config_example_path = os.path.normpath(os.path.join(PLUGIN_DIR, 'config.json.example'))
|
|
43
45
|
|
|
44
46
|
print(f"Looking for config at: {config_path}")
|
|
45
47
|
|
|
46
48
|
if not os.path.exists(config_path):
|
|
47
|
-
|
|
49
|
+
if os.path.exists(config_example_path):
|
|
50
|
+
print("Config file not found, copying from config.json.example...")
|
|
51
|
+
import shutil
|
|
52
|
+
shutil.copy(config_example_path, config_path)
|
|
53
|
+
print(f"Created config.json from template")
|
|
54
|
+
else:
|
|
55
|
+
raise FileNotFoundError(f"Config file not found: {config_path}")
|
|
48
56
|
|
|
49
57
|
try:
|
|
50
58
|
with open(config_path, 'r', encoding='utf-8') as f:
|
|
@@ -52,6 +60,24 @@ class SoulSyncPlugin:
|
|
|
52
60
|
except json.JSONDecodeError as e:
|
|
53
61
|
raise ValueError(f"Invalid JSON in config.json: {e}")
|
|
54
62
|
|
|
63
|
+
# 检查必要配置
|
|
64
|
+
cloud_url = self.config.get('cloud_url', '').strip()
|
|
65
|
+
email = self.config.get('email', '').strip()
|
|
66
|
+
password = self.config.get('password', '').strip()
|
|
67
|
+
|
|
68
|
+
# 如果 cloud_url 为空,设置为默认值
|
|
69
|
+
if not cloud_url:
|
|
70
|
+
self.config['cloud_url'] = 'https://soulsync.work'
|
|
71
|
+
print("Cloud URL not set, using default: https://soulsync.work")
|
|
72
|
+
|
|
73
|
+
# 如果 email 或 password 为空,需要交互式认证
|
|
74
|
+
if not email or not password:
|
|
75
|
+
print("\nEmail or password not configured, initiating interactive setup...")
|
|
76
|
+
self._interactive_setup()
|
|
77
|
+
# 重新加载配置
|
|
78
|
+
with open(config_path, 'r', encoding='utf-8') as f:
|
|
79
|
+
self.config = json.load(f)
|
|
80
|
+
|
|
55
81
|
# 处理 workspace 路径
|
|
56
82
|
workspace = self.config.get('workspace', './workspace')
|
|
57
83
|
if workspace.startswith('./'):
|
|
@@ -68,6 +94,186 @@ class SoulSyncPlugin:
|
|
|
68
94
|
print(f" Workspace: {workspace}")
|
|
69
95
|
print(f" Watch files: {watch_files}")
|
|
70
96
|
|
|
97
|
+
def _interactive_setup(self):
|
|
98
|
+
"""交互式设置:引导用户登录或注册"""
|
|
99
|
+
from register import Register, Login
|
|
100
|
+
from interactive_auth import interactive_setup
|
|
101
|
+
|
|
102
|
+
while True:
|
|
103
|
+
print("\n" + "=" * 50)
|
|
104
|
+
print("Welcome / 欢迎使用 SoulSync")
|
|
105
|
+
print("=" * 50)
|
|
106
|
+
print("1. Login / 登录(已有账号)")
|
|
107
|
+
print("2. Register / 注册(新用户)")
|
|
108
|
+
print("3. Exit / 退出")
|
|
109
|
+
|
|
110
|
+
choice = input("Choose / 选择 (1/2/3): ").strip()
|
|
111
|
+
|
|
112
|
+
if choice == '1':
|
|
113
|
+
success = self._interactive_login()
|
|
114
|
+
if success:
|
|
115
|
+
return True
|
|
116
|
+
elif choice == '2':
|
|
117
|
+
success = self._interactive_register()
|
|
118
|
+
if success:
|
|
119
|
+
return True
|
|
120
|
+
elif choice == '3':
|
|
121
|
+
print("Exiting... / 退出...")
|
|
122
|
+
sys.exit(0)
|
|
123
|
+
else:
|
|
124
|
+
print("Invalid choice / 无效选择")
|
|
125
|
+
|
|
126
|
+
def _interactive_login(self):
|
|
127
|
+
"""交互式登录(带重试)"""
|
|
128
|
+
max_retries = 5
|
|
129
|
+
retry_count = 0
|
|
130
|
+
|
|
131
|
+
while retry_count < max_retries:
|
|
132
|
+
print("\n--- Login / 登录 ---")
|
|
133
|
+
email = input("Email / 邮箱: ").strip()
|
|
134
|
+
if not email:
|
|
135
|
+
print("Email cannot be empty / 邮箱不能为空")
|
|
136
|
+
continue
|
|
137
|
+
|
|
138
|
+
password = getpass.getpass("Password / 密码: ")
|
|
139
|
+
if not password:
|
|
140
|
+
print("Password cannot be empty / 密码不能为空")
|
|
141
|
+
continue
|
|
142
|
+
|
|
143
|
+
try:
|
|
144
|
+
temp_client = OpenClawClient(self.config)
|
|
145
|
+
result = temp_client.authenticate(email, password)
|
|
146
|
+
if result:
|
|
147
|
+
print("\n✅ Login successful! / 登录成功!")
|
|
148
|
+
self._save_auth_to_config(result)
|
|
149
|
+
return True
|
|
150
|
+
except Exception as e:
|
|
151
|
+
retry_count += 1
|
|
152
|
+
remaining = max_retries - retry_count
|
|
153
|
+
error_msg = str(e)
|
|
154
|
+
|
|
155
|
+
if "429" in error_msg or "too many" in error_msg.lower():
|
|
156
|
+
print(f"\n❌ {e}")
|
|
157
|
+
print("\nToo many failed attempts / 登录失败次数过多")
|
|
158
|
+
print("Exiting... / 退出...")
|
|
159
|
+
sys.exit(0)
|
|
160
|
+
|
|
161
|
+
if remaining > 0:
|
|
162
|
+
print(f"\n❌ Login failed: {e} / 登录失败: {e}")
|
|
163
|
+
print(f"Remaining attempts / 剩余尝试次数: {remaining}")
|
|
164
|
+
else:
|
|
165
|
+
print(f"\n❌ Login failed: {e} / 登录失败: {e}")
|
|
166
|
+
|
|
167
|
+
print("\n❌ Too many failed attempts. Please try again in 15 minutes. / 登录失败次数过多,请15分钟后再试")
|
|
168
|
+
print("Exiting... / 退出...")
|
|
169
|
+
sys.exit(0)
|
|
170
|
+
|
|
171
|
+
def _interactive_register(self):
|
|
172
|
+
"""交互式注册(带重试)"""
|
|
173
|
+
from register import Register
|
|
174
|
+
|
|
175
|
+
max_retries = 5
|
|
176
|
+
retry_count = 0
|
|
177
|
+
|
|
178
|
+
while retry_count < max_retries:
|
|
179
|
+
print("\n--- Register / 注册 ---")
|
|
180
|
+
email = input("Email / 邮箱: ").strip()
|
|
181
|
+
if not email or '@' not in email:
|
|
182
|
+
print("Invalid email / 无效邮箱")
|
|
183
|
+
continue
|
|
184
|
+
|
|
185
|
+
password = getpass.getpass("Password / 密码: ")
|
|
186
|
+
if len(password) < 6:
|
|
187
|
+
print("Password must be at least 6 characters / 密码至少6位")
|
|
188
|
+
continue
|
|
189
|
+
|
|
190
|
+
password2 = getpass.getpass("Confirm password / 确认密码: ")
|
|
191
|
+
if password != password2:
|
|
192
|
+
print("Passwords do not match / 两次密码不一致")
|
|
193
|
+
continue
|
|
194
|
+
|
|
195
|
+
# 发送验证码
|
|
196
|
+
print(f"\nSending verification code to {email}...")
|
|
197
|
+
try:
|
|
198
|
+
temp_client = OpenClawClient(self.config)
|
|
199
|
+
temp_client.send_verification_code(email)
|
|
200
|
+
print("✅ Verification code sent! / 验证码已发送!")
|
|
201
|
+
except Exception as e:
|
|
202
|
+
print(f"❌ Failed to send code: {e}")
|
|
203
|
+
continue
|
|
204
|
+
|
|
205
|
+
# 验证码输入(带重试)
|
|
206
|
+
code_retry = 0
|
|
207
|
+
while code_retry < max_retries:
|
|
208
|
+
code = input(f"Enter verification code / 请输入验证码 ({max_retries - code_retry} attempts left): ").strip()
|
|
209
|
+
if len(code) != 6 or not code.isdigit():
|
|
210
|
+
code_retry += 1
|
|
211
|
+
print("Invalid code format / 验证码格式错误")
|
|
212
|
+
continue
|
|
213
|
+
|
|
214
|
+
try:
|
|
215
|
+
result = temp_client.register(email, password, code)
|
|
216
|
+
print("\n✅ Registration successful! / 注册成功!")
|
|
217
|
+
self._save_auth_to_config(result)
|
|
218
|
+
return True
|
|
219
|
+
except Exception as e:
|
|
220
|
+
code_retry += 1
|
|
221
|
+
remaining_code = max_retries - code_retry
|
|
222
|
+
if "invalid" in str(e).lower() or "expired" in str(e).lower():
|
|
223
|
+
if remaining_code > 0:
|
|
224
|
+
print(f"❌ Invalid or expired code: {e}")
|
|
225
|
+
print(f"Remaining attempts / 剩余尝试: {remaining_code}")
|
|
226
|
+
else:
|
|
227
|
+
print("❌ Too many code attempts / 验证码错误次数过多")
|
|
228
|
+
break
|
|
229
|
+
else:
|
|
230
|
+
print(f"❌ Registration failed: {e}")
|
|
231
|
+
break
|
|
232
|
+
|
|
233
|
+
if code_retry >= max_retries:
|
|
234
|
+
print("\nToo many code verification failures. Would you like to:")
|
|
235
|
+
print("1. Resend code / 重新发送验证码")
|
|
236
|
+
print("2. Start over / 重新开始")
|
|
237
|
+
print("3. Exit / 退出")
|
|
238
|
+
|
|
239
|
+
sub_choice = input("Choose / 选择 (1/2/3): ").strip()
|
|
240
|
+
if sub_choice == '1':
|
|
241
|
+
retry_count = 0 # 重置主重试计数
|
|
242
|
+
continue
|
|
243
|
+
elif sub_choice == '2':
|
|
244
|
+
retry_count = 0
|
|
245
|
+
break # 跳出内层循环,继续外层循环
|
|
246
|
+
else:
|
|
247
|
+
print("Exiting... / 退出...")
|
|
248
|
+
sys.exit(0)
|
|
249
|
+
|
|
250
|
+
print("\n❌ Too many registration attempts / 注册尝试次数过多")
|
|
251
|
+
print("Exiting... / 退出...")
|
|
252
|
+
sys.exit(0)
|
|
253
|
+
|
|
254
|
+
def _save_auth_to_config(self, auth_result):
|
|
255
|
+
"""保存认证结果到 config.json"""
|
|
256
|
+
config_path = os.path.normpath(os.path.join(PLUGIN_DIR, 'config.json'))
|
|
257
|
+
|
|
258
|
+
try:
|
|
259
|
+
with open(config_path, 'r', encoding='utf-8') as f:
|
|
260
|
+
config = json.load(f)
|
|
261
|
+
except:
|
|
262
|
+
config = {}
|
|
263
|
+
|
|
264
|
+
# 保存 email 和 password(如果 auth_result 包含)
|
|
265
|
+
if 'user' in auth_result:
|
|
266
|
+
config['email'] = auth_result['user'].get('email', '')
|
|
267
|
+
|
|
268
|
+
# 保存 token
|
|
269
|
+
if 'token' in auth_result:
|
|
270
|
+
config['token'] = auth_result['token']
|
|
271
|
+
|
|
272
|
+
with open(config_path, 'w', encoding='utf-8') as f:
|
|
273
|
+
json.dump(config, f, indent=2, ensure_ascii=False)
|
|
274
|
+
|
|
275
|
+
print("Auth info saved to config.json")
|
|
276
|
+
|
|
71
277
|
def initialize(self):
|
|
72
278
|
"""初始化组件"""
|
|
73
279
|
print("\n=== Initializing SoulSync Plugin ===\n")
|
|
@@ -80,11 +286,11 @@ class SoulSyncPlugin:
|
|
|
80
286
|
profile = self.client.get_profile()
|
|
81
287
|
print(f"Using existing token, user: {profile.get('email', 'unknown')}")
|
|
82
288
|
except Exception as e:
|
|
83
|
-
print(f"Token invalid
|
|
289
|
+
print(f"Token invalid / 令牌无效, re-authenticating: {e}")
|
|
84
290
|
token = None
|
|
85
291
|
|
|
86
292
|
if not token:
|
|
87
|
-
print("\n===
|
|
293
|
+
print("\n=== Token invalid - Please login or register / 令牌无效,请先登录或注册 ===\n")
|
|
88
294
|
print("1. Login / 登录(已有账号)")
|
|
89
295
|
print("2. Register / 注册(新用户)")
|
|
90
296
|
|
package/src/main_fixed.py
CHANGED