koishi-plugin-cocoyyy-console 1.1.4 → 1.1.5

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.
Files changed (2) hide show
  1. package/lib/index.js +30 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1910,6 +1910,34 @@ function safeParseJSON(jsonString) {
1910
1910
  }
1911
1911
  }
1912
1912
  __name(safeParseJSON, "safeParseJSON");
1913
+ function findNestedValue(obj, key) {
1914
+ if (obj === null || obj === void 0) {
1915
+ return void 0;
1916
+ }
1917
+ if (typeof obj === "object" && !Array.isArray(obj)) {
1918
+ if (key in obj) {
1919
+ return obj[key];
1920
+ }
1921
+ for (const prop in obj) {
1922
+ if (obj.hasOwnProperty(prop)) {
1923
+ const result = findNestedValue(obj[prop], key);
1924
+ if (result !== void 0) {
1925
+ return result;
1926
+ }
1927
+ }
1928
+ }
1929
+ }
1930
+ if (Array.isArray(obj)) {
1931
+ for (const item of obj) {
1932
+ const result = findNestedValue(item, key);
1933
+ if (result !== void 0) {
1934
+ return result;
1935
+ }
1936
+ }
1937
+ }
1938
+ return void 0;
1939
+ }
1940
+ __name(findNestedValue, "findNestedValue");
1913
1941
  async function checkAudit(local_config4, wish_content, config, wish_config) {
1914
1942
  let prompt_msg = "";
1915
1943
  if (!local_config4) return { result: false, reason: "未加载配置文件,请查看日志" };
@@ -1979,9 +2007,9 @@ async function gernerationSoluation(local_config4, wish_content, config, wish_co
1979
2007
  return null;
1980
2008
  }
1981
2009
  const json = safeParseJSON(resp);
1982
- const scenario = json.scenario;
2010
+ const scenario = json.scenario || findNestedValue(json, "scenario");
1983
2011
  if (!scenario) {
1984
- logger.info("[gernerationSoluation Info]: API返回有误: " + resp);
2012
+ logger.info("[gernerationSoluation Info]: API返回有误,未找到scenario字段: " + resp);
1985
2013
  return null;
1986
2014
  }
1987
2015
  return scenario;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-cocoyyy-console",
3
3
  "description": "自用koishi插件,功能包含复读,记录黑历史,*人等",
4
- "version": "1.1.4",
4
+ "version": "1.1.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [