|
1290 | 1290 | return responseData.inputSettings.text || ''; |
1291 | 1291 | } |
1292 | 1292 |
|
1293 | | -function parseTimerText(timerText) { |
1294 | | - if (!timerText || timerText === '--:--') return null; |
1295 | | - const clean = String(timerText).trim().replace(/^\+/, ''); |
1296 | | - const parts = clean.split(':').map(part => parseInt(part, 10)); |
1297 | | - if (parts.some(Number.isNaN)) return null; |
1298 | | - if (parts.length === 2) return (parts[0] * 60) + parts[1]; |
1299 | | - if (parts.length === 3) return (parts[0] * 3600) + (parts[1] * 60) + parts[2]; |
1300 | | - return null; |
1301 | | -} |
1302 | | - |
1303 | | -function inferSessionType(messageText) { |
1304 | | - const text = String(messageText || '').toLowerCase(); |
1305 | | - if (text.includes('short break')) return 'Short Break'; |
1306 | | - if (text.includes('long break')) return 'Long Break'; |
1307 | | - if (text.includes('focus')) return 'Focus'; |
1308 | | - if (text.includes('countdown')) return 'Countdown'; |
1309 | | - if (text.includes('stopwatch')) return 'Stopwatch'; |
1310 | | - return ''; |
1311 | | -} |
1312 | | - |
1313 | | -function parseCountText(countText) { |
1314 | | - const match = String(countText || '').match(/(\d+)\s*\/\s*(\d+)/); |
1315 | | - if (!match) return { completed: 0, goal: 0 }; |
1316 | | - return { |
1317 | | - completed: parseInt(match[1], 10) || 0, |
1318 | | - goal: parseInt(match[2], 10) || 0 |
1319 | | - }; |
1320 | | -} |
1321 | | - |
1322 | | -function parseProgressText(progressText) { |
1323 | | - const filled = (String(progressText || '').match(/█/g) || []).length; |
1324 | | - const empty = (String(progressText || '').match(/░/g) || []).length; |
1325 | | - const total = filled + empty; |
1326 | | - if (total <= 0) return 0; |
1327 | | - return Math.round((filled / total) * 100); |
1328 | | -} |
1329 | | - |
1330 | 1293 | function parseControlBridgeState(controlText) { |
1331 | 1294 | if (!controlText) return null; |
1332 | 1295 |
|
|
1339 | 1302 | } |
1340 | 1303 | } |
1341 | 1304 |
|
1342 | | -function buildFallbackChatStatus(sessionText, timerText, countText, paused) { |
1343 | | - const parts = []; |
1344 | | - if (sessionText) parts.push(String(sessionText).trim()); |
1345 | | - if (timerText) parts.push(String(timerText).trim()); |
1346 | | - if (countText) parts.push(`(${String(countText).trim()})`); |
1347 | | - let summary = parts.join(' '); |
1348 | | - if (paused && summary && !/\bpaused\b/i.test(summary)) { |
1349 | | - summary += ' [Paused]'; |
1350 | | - } |
1351 | | - return summary || '--'; |
1352 | | -} |
1353 | | - |
1354 | 1305 | async function loadStateViaObsSources() { |
1355 | 1306 | // Read SP Control text source — this contains the full state JSON |
1356 | 1307 | // written by the Lua script every tick via update_control_bridge_state(). |
|
0 commit comments