koishi-plugin-oni-sync-bot 0.9.2 → 0.9.3
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/lib/index.js +16 -7
- package/lib/plugins/queryCommands.d.ts +1 -0
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -2022,6 +2022,12 @@ bwiki: https://${this.config.domain}/bw/88888888`;
|
|
|
2022
2022
|
}
|
|
2023
2023
|
return null;
|
|
2024
2024
|
}
|
|
2025
|
+
getCommonPrefixLength(a, b) {
|
|
2026
|
+
const minLen = Math.min(a.length, b.length);
|
|
2027
|
+
let i = 0;
|
|
2028
|
+
while (i < minLen && a[i] === b[i]) i++;
|
|
2029
|
+
return i;
|
|
2030
|
+
}
|
|
2025
2031
|
calculateScore(page, queryKey, queryPinyinFull, queryPinyinFirst) {
|
|
2026
2032
|
let score = 0;
|
|
2027
2033
|
const { title, pinyin_full, pinyin_first } = page;
|
|
@@ -2029,13 +2035,16 @@ bwiki: https://${this.config.domain}/bw/88888888`;
|
|
|
2029
2035
|
if (pinyin_full.startsWith(queryPinyinFull)) score += 9;
|
|
2030
2036
|
if (pinyin_full.includes(queryPinyinFull)) score += 8;
|
|
2031
2037
|
if (pinyin_first.includes(queryPinyinFirst)) score += 6;
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2038
|
+
const titlePrefixLen = this.getCommonPrefixLength(title, queryKey);
|
|
2039
|
+
if (titlePrefixLen >= 2) {
|
|
2040
|
+
score += titlePrefixLen;
|
|
2041
|
+
}
|
|
2042
|
+
const pinyinPrefixLen = this.getCommonPrefixLength(
|
|
2043
|
+
pinyin_full,
|
|
2044
|
+
queryPinyinFull
|
|
2045
|
+
);
|
|
2046
|
+
if (pinyinPrefixLen >= 3) {
|
|
2047
|
+
score += Math.floor(pinyinPrefixLen / 2);
|
|
2039
2048
|
}
|
|
2040
2049
|
return score;
|
|
2041
2050
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-oni-sync-bot",
|
|
3
3
|
"description": "缺氧Wiki站镜像点同步-测试",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.3",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"koishi-plugin-cron": "^3.1.0",
|
|
35
35
|
"mwn": "^3.0.3",
|
|
36
36
|
"node-fetch": "^3.3.2",
|
|
37
|
-
"pinyin-pro": "^3.
|
|
37
|
+
"pinyin-pro": "^3.29.1"
|
|
38
38
|
}
|
|
39
39
|
}
|