Skip to content

Commit

Permalink
feat: modifyPegasusQueryContext
Browse files Browse the repository at this point in the history
Update modifyPegasusQueryContext.mjs
  • Loading branch information
VirgilClyne committed Dec 17, 2024
1 parent 9ac8960 commit b2ff43b
Showing 1 changed file with 40 additions and 38 deletions.
78 changes: 40 additions & 38 deletions src/function/modifyPegasusQueryContext.mjs
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import { Console } from "@nsnanocat/util";

export default function modifyPegasusQueryContext(queryContext, Settings) {
Console.log("☑️ modify PegasusQueryContext");
const Locale = queryContext.locale;
const [Language, CountryCode] = Locale?.split("_") ?? [];
Console.info(`Locale: ${Locale}`, `Language: ${Language}`, `CountryCode: ${CountryCode}`);
switch (Settings.CountryCode) {
// biome-ignore lint/suspicious/noFallthroughSwitchClause: <explanation>
case "AUTO":
Settings.CountryCode = CountryCode;
default:
queryContext.countryCode = Settings.CountryCode;

break;
};
switch (Settings.Region) {
case "AUTO":
break;
default:
queryContext.region = Settings.CountryCode;
break;
};
switch (Settings.SiriLocale) {
case "AUTO":
break;
default:
queryContext.siriLocale = Settings.SiriLocale;
break;
};
switch (Settings.SiriResponseLanguageVariant) {
case "AUTO":
break;
default:
queryContext.siriResponseLanguageVariant = Settings.SiriResponseLanguageVariant;
break;
};
if (queryContext?.skuRegion === "CH") queryContext.skuRegion = "LL";
Console.log("✅ modify PegasusQueryContext");
return queryContext;
};
Console.log("☑️ modify PegasusQueryContext");
const Locale = queryContext.locale;
const [Language, CountryCode] = Locale?.split("_") ?? [];
Console.info(`Locale: ${Locale}`, `Language: ${Language}`, `CountryCode: ${CountryCode}`);
switch (Settings.CountryCode) {
case "AUTO":
queryContext.CountryCode = CountryCode;
break;
default:
queryContext.countryCode = Settings.CountryCode;
break;
}
switch (Settings.Region) {
case "AUTO":
queryContext.region = CountryCode;
break;
default:
queryContext.region = Settings.Region;
break;
}
switch (Settings.SiriLocale) {
case "AUTO":
queryContext.siriLocale = Locale;
break;
default:
queryContext.siriLocale = Settings.SiriLocale;
break;
}
switch (Settings.SiriResponseLanguageVariant) {
case "AUTO":
queryContext.siriResponseLanguageVariant = Locale;
break;
default:
queryContext.siriResponseLanguageVariant = Settings.SiriResponseLanguageVariant;
break;
}
if (queryContext?.skuRegion === "CH") queryContext.skuRegion = "LL";
Console.log("✅ modify PegasusQueryContext");
return queryContext;
}

0 comments on commit b2ff43b

Please sign in to comment.