koishi-plugin-bilibili-notify 3.2.9-rc.0 → 3.2.9-rc.1
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 +64 -229
- package/lib/index.mjs +64 -229
- package/lib/static/render.js +107 -0
- package/package.json +1 -1
- package/readme.md +1 -0
package/lib/index.js
CHANGED
|
@@ -799,196 +799,56 @@ var ComRegister = class {
|
|
|
799
799
|
});
|
|
800
800
|
biliCom.subcommand(".wc").action(async ({ session }) => {
|
|
801
801
|
const words = [
|
|
802
|
-
["
|
|
803
|
-
["
|
|
804
|
-
["
|
|
805
|
-
["
|
|
806
|
-
["
|
|
807
|
-
["
|
|
808
|
-
["
|
|
809
|
-
["
|
|
810
|
-
["
|
|
811
|
-
["
|
|
812
|
-
["
|
|
813
|
-
["
|
|
814
|
-
["
|
|
815
|
-
["
|
|
816
|
-
["
|
|
817
|
-
["
|
|
818
|
-
["
|
|
819
|
-
["
|
|
820
|
-
["
|
|
821
|
-
["
|
|
822
|
-
["
|
|
823
|
-
["
|
|
824
|
-
["
|
|
825
|
-
["
|
|
826
|
-
["
|
|
827
|
-
["
|
|
828
|
-
["
|
|
829
|
-
["
|
|
830
|
-
["
|
|
831
|
-
["
|
|
832
|
-
["
|
|
833
|
-
["
|
|
834
|
-
["
|
|
835
|
-
["
|
|
836
|
-
["
|
|
837
|
-
["
|
|
838
|
-
["
|
|
839
|
-
["
|
|
840
|
-
["
|
|
841
|
-
["
|
|
842
|
-
["
|
|
843
|
-
["
|
|
844
|
-
["
|
|
845
|
-
["
|
|
846
|
-
["
|
|
847
|
-
["
|
|
848
|
-
["
|
|
849
|
-
["
|
|
850
|
-
["
|
|
851
|
-
["
|
|
852
|
-
["k1q8z", 102],
|
|
853
|
-
["v7n2a", 31],
|
|
854
|
-
["b4x9p", 176],
|
|
855
|
-
["w2m5s", 61],
|
|
856
|
-
["t8j3u", 150],
|
|
857
|
-
["z5c7l", 84],
|
|
858
|
-
["h2r8y", 196],
|
|
859
|
-
["n9d1q", 44],
|
|
860
|
-
["p6s3e", 123],
|
|
861
|
-
["f8g2b", 17],
|
|
862
|
-
["m1v7k", 109],
|
|
863
|
-
["x4a9w", 72],
|
|
864
|
-
["c7t2z", 180],
|
|
865
|
-
["u5b8n", 38],
|
|
866
|
-
["e1y3h", 134],
|
|
867
|
-
["j8l6p", 56],
|
|
868
|
-
["s2q9d", 191],
|
|
869
|
-
["g7m4x", 25],
|
|
870
|
-
["a5w8c", 113],
|
|
871
|
-
["l9h2v", 68],
|
|
872
|
-
["y1k7t", 159],
|
|
873
|
-
["d8z3u", 45],
|
|
874
|
-
["q2e6j", 177],
|
|
875
|
-
["r7p1s", 80],
|
|
876
|
-
["b5n9f", 126],
|
|
877
|
-
["v1x4m", 32],
|
|
878
|
-
["t7c8w", 198],
|
|
879
|
-
["z4u2h", 54],
|
|
880
|
-
["h9y5j", 143],
|
|
881
|
-
["n2l7s", 19],
|
|
882
|
-
["p8d1g", 104],
|
|
883
|
-
["f5b3a", 67],
|
|
884
|
-
["m2v9x", 171],
|
|
885
|
-
["x8a4c", 40],
|
|
886
|
-
["c1t7u", 187],
|
|
887
|
-
["u4b2e", 28],
|
|
888
|
-
["e9y6k", 135],
|
|
889
|
-
["j2l8q", 60],
|
|
890
|
-
["s7g1m", 119],
|
|
891
|
-
["g4w5t", 76],
|
|
892
|
-
["a9z2h", 164],
|
|
893
|
-
["l1h7p", 35],
|
|
894
|
-
["y8k3n", 185],
|
|
895
|
-
["d2u9f", 22],
|
|
896
|
-
["q7e4v", 110],
|
|
897
|
-
["r5p8x", 69],
|
|
898
|
-
["b1n6c", 152],
|
|
899
|
-
["v8x2w", 48],
|
|
900
|
-
["t4c7a", 142],
|
|
901
|
-
["z7u1j", 99],
|
|
902
|
-
["k2q5z", 174],
|
|
903
|
-
["v9n8a", 37],
|
|
904
|
-
["b6x3p", 189],
|
|
905
|
-
["w1m7s", 24],
|
|
906
|
-
["t5j2u", 115],
|
|
907
|
-
["z1c8l", 63],
|
|
908
|
-
["h6r4y", 155],
|
|
909
|
-
["n3d9q", 50],
|
|
910
|
-
["p7s2e", 137],
|
|
911
|
-
["f9g1b", 81],
|
|
912
|
-
["m4v6k", 170],
|
|
913
|
-
["x1a8w", 42],
|
|
914
|
-
["c8t3z", 194],
|
|
915
|
-
["u2b7n", 26],
|
|
916
|
-
["e5y9h", 130],
|
|
917
|
-
["j9l1p", 58],
|
|
918
|
-
["s4q6d", 182],
|
|
919
|
-
["g1m8x", 33],
|
|
920
|
-
["a8w5c", 108],
|
|
921
|
-
["l3h9v", 75],
|
|
922
|
-
["y2k4t", 161],
|
|
923
|
-
["d9z1u", 46],
|
|
924
|
-
["q5e8j", 149],
|
|
925
|
-
["r2p7s", 20],
|
|
926
|
-
["b9n3f", 122],
|
|
927
|
-
["v4x6m", 65],
|
|
928
|
-
["t1c9w", 179],
|
|
929
|
-
["z8u5h", 30],
|
|
930
|
-
["h3y2j", 136],
|
|
931
|
-
["n5l8s", 52],
|
|
932
|
-
["p1d4g", 167],
|
|
933
|
-
["f6b9a", 95],
|
|
934
|
-
["m3v2x", 156],
|
|
935
|
-
["x9a5c", 43],
|
|
936
|
-
["c2t8u", 192],
|
|
937
|
-
["u7b1e", 16],
|
|
938
|
-
["e4y6k", 129],
|
|
939
|
-
["j5l3q", 78],
|
|
940
|
-
["s1g9m", 118],
|
|
941
|
-
["g8w2t", 71],
|
|
942
|
-
["a3z7h", 173],
|
|
943
|
-
["l6h1p", 36],
|
|
944
|
-
["y9k5n", 184],
|
|
945
|
-
["d1u8f", 15],
|
|
946
|
-
["q8e3v", 111],
|
|
947
|
-
["r4p6x", 64],
|
|
948
|
-
["b2n7c", 151],
|
|
949
|
-
["v5x1w", 47],
|
|
950
|
-
["t8c4a", 140],
|
|
951
|
-
["z3u9j", 98],
|
|
952
|
-
["k7q2z", 176],
|
|
953
|
-
["v1n5a", 55],
|
|
954
|
-
["b8x6p", 195],
|
|
955
|
-
["w3m1s", 14],
|
|
956
|
-
["t6j9u", 116],
|
|
957
|
-
["z2c5l", 61],
|
|
958
|
-
["h7r3y", 153],
|
|
959
|
-
["n4d8q", 51],
|
|
960
|
-
["p2s7e", 139],
|
|
961
|
-
["f7g5b", 82],
|
|
962
|
-
["m9v1k", 169],
|
|
963
|
-
["x5a3w", 38],
|
|
964
|
-
["c9t6z", 197],
|
|
965
|
-
["u3b8n", 17],
|
|
966
|
-
["e6y2h", 131],
|
|
967
|
-
["j7l5p", 59],
|
|
968
|
-
["s3q8d", 181],
|
|
969
|
-
["g2m4x", 34],
|
|
970
|
-
["a6w9c", 107],
|
|
971
|
-
["l8h2v", 74],
|
|
972
|
-
["y4k7t", 162],
|
|
973
|
-
["d6z5u", 49],
|
|
974
|
-
["q3e1j", 148],
|
|
975
|
-
["r9p2s", 21],
|
|
976
|
-
["b4n8f", 121],
|
|
977
|
-
["v7x5m", 68],
|
|
978
|
-
["t2c1w", 178],
|
|
979
|
-
["z5u3h", 31],
|
|
980
|
-
["h8y6j", 133],
|
|
981
|
-
["n1l4s", 57],
|
|
982
|
-
["p5d7g", 166],
|
|
983
|
-
["f3b2a", 96],
|
|
984
|
-
["m6v8x", 158],
|
|
985
|
-
["x2a9c", 45],
|
|
986
|
-
["c5t1u", 191],
|
|
987
|
-
["u8b4e", 19],
|
|
988
|
-
["e3y7k", 128],
|
|
989
|
-
["j6l2q", 79],
|
|
990
|
-
["s9g5m", 114],
|
|
991
|
-
["g5w3t", 73]
|
|
802
|
+
["弹幕护体", 77],
|
|
803
|
+
["笑死", 30],
|
|
804
|
+
["泪目", 45],
|
|
805
|
+
["加油", 70],
|
|
806
|
+
["???", 80],
|
|
807
|
+
["我可以", 66],
|
|
808
|
+
["无语", 55],
|
|
809
|
+
["梦开始的地方", 1],
|
|
810
|
+
["太真实了", 8],
|
|
811
|
+
["我哭死", 1],
|
|
812
|
+
["人呢", 2],
|
|
813
|
+
["有点意思", 4],
|
|
814
|
+
["妙啊", 4],
|
|
815
|
+
["这波啊", 11],
|
|
816
|
+
["懂了", 6],
|
|
817
|
+
["破防了", 65],
|
|
818
|
+
["蚌埠住了", 92],
|
|
819
|
+
["草", 100],
|
|
820
|
+
["针不戳", 68],
|
|
821
|
+
["yyds", 50],
|
|
822
|
+
["DNA动了", 58],
|
|
823
|
+
["猝不及防", 40],
|
|
824
|
+
["建议加精", 15],
|
|
825
|
+
["保护", 22],
|
|
826
|
+
["害怕", 18],
|
|
827
|
+
["就这?", 99],
|
|
828
|
+
["2333", 20],
|
|
829
|
+
["公开处刑", 35],
|
|
830
|
+
["血压上来了", 45],
|
|
831
|
+
["整不会了", 32],
|
|
832
|
+
["见证历史", 88],
|
|
833
|
+
["下次一定", 65],
|
|
834
|
+
["奥利给", 56],
|
|
835
|
+
["求更新", 18],
|
|
836
|
+
["真实", 20],
|
|
837
|
+
["好活当赏", 25],
|
|
838
|
+
["泪,冲了出来", 68],
|
|
839
|
+
["刻进DNA", 70],
|
|
840
|
+
["我直接好家伙", 55],
|
|
841
|
+
["夺笋啊", 40],
|
|
842
|
+
["歪歪滴艾斯", 1],
|
|
843
|
+
["典中典", 5],
|
|
844
|
+
["麻中麻", 3],
|
|
845
|
+
["绷不住了", 8],
|
|
846
|
+
["逆天", 95],
|
|
847
|
+
["寄", 65],
|
|
848
|
+
["孝", 20],
|
|
849
|
+
["乐", 101],
|
|
850
|
+
["急急急", 3],
|
|
851
|
+
["典", 5]
|
|
992
852
|
];
|
|
993
853
|
await session.send(/* @__PURE__ */ (0, __satorijs_element_jsx_runtime.jsx)("message", { children: koishi.h.image(await this.ctx.gi.generateWordCloudImg(words, "词云测试"), "image/jpg") }));
|
|
994
854
|
});
|
|
@@ -1436,12 +1296,12 @@ var ComRegister = class {
|
|
|
1436
1296
|
const liveMsgObj = this.liveMsgManager.get(uid);
|
|
1437
1297
|
const sendDanmakuWordCloud = async () => {
|
|
1438
1298
|
this.logger.info("开始制作弹幕词云");
|
|
1439
|
-
this.logger.info("正在获取前
|
|
1440
|
-
const
|
|
1441
|
-
this.logger.info("弹幕词云前
|
|
1442
|
-
this.logger.info(
|
|
1299
|
+
this.logger.info("正在获取前50热词");
|
|
1300
|
+
const top50Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 50);
|
|
1301
|
+
this.logger.info("弹幕词云前50词及权重:");
|
|
1302
|
+
this.logger.info(top50Words);
|
|
1443
1303
|
this.logger.info("正在准备生成弹幕词云");
|
|
1444
|
-
const buffer = await this.ctx.gi.generateWordCloudImg(
|
|
1304
|
+
const buffer = await this.ctx.gi.generateWordCloudImg(top50Words, masterInfo.username);
|
|
1445
1305
|
this.logger.info("弹幕词云生成完成,正在准备发送词云图片");
|
|
1446
1306
|
await this.broadcastToTargets(uid, koishi.h.image(buffer, "image/jpeg"), PushType.Live);
|
|
1447
1307
|
};
|
|
@@ -84385,6 +84245,7 @@ var require_tar_fs = __commonJS$1({ "node_modules/tar-fs/index.js"(exports) {
|
|
|
84385
84245
|
const now = /* @__PURE__ */ new Date();
|
|
84386
84246
|
const umask = typeof opts.umask === "number" ? ~opts.umask : ~processUmask();
|
|
84387
84247
|
const strict = opts.strict !== false;
|
|
84248
|
+
const validateSymLinks = opts.validateSymlinks !== false;
|
|
84388
84249
|
let map = opts.map || noop;
|
|
84389
84250
|
let dmode = typeof opts.dmode === "number" ? opts.dmode : 0;
|
|
84390
84251
|
let fmode = typeof opts.fmode === "number" ? opts.fmode : 0;
|
|
@@ -84452,7 +84313,7 @@ var require_tar_fs = __commonJS$1({ "node_modules/tar-fs/index.js"(exports) {
|
|
|
84452
84313
|
if (win32$1) return next();
|
|
84453
84314
|
xfs.unlink(name$3, function() {
|
|
84454
84315
|
const dst = path$4.resolve(path$4.dirname(name$3), header.linkname);
|
|
84455
|
-
if (!inCwd(dst)) return next(/* @__PURE__ */ new Error(name$3 + " is not a valid symlink"));
|
|
84316
|
+
if (!inCwd(dst) && validateSymLinks) return next(/* @__PURE__ */ new Error(name$3 + " is not a valid symlink"));
|
|
84456
84317
|
xfs.symlink(header.linkname, name$3, stat);
|
|
84457
84318
|
});
|
|
84458
84319
|
}
|
|
@@ -94533,6 +94394,7 @@ var GenerateImg = class extends koishi.Service {
|
|
|
94533
94394
|
async generateWordCloudImg(words, masterName) {
|
|
94534
94395
|
const fontURL = (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
94535
94396
|
const wordcloudJS = (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "static/wordcloud2.min.js"));
|
|
94397
|
+
const renderFunc = (0, node_url.pathToFileURL)((0, node_path.resolve)(__dirname, "static/render.js"));
|
|
94536
94398
|
const html = `
|
|
94537
94399
|
<!DOCTYPE html>
|
|
94538
94400
|
<html lang="zh-CN">
|
|
@@ -94540,7 +94402,6 @@ var GenerateImg = class extends koishi.Service {
|
|
|
94540
94402
|
<head>
|
|
94541
94403
|
<meta charset="UTF-8">
|
|
94542
94404
|
<title>高清词云展示</title>
|
|
94543
|
-
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@500&display=swap" rel="stylesheet">
|
|
94544
94405
|
<style>
|
|
94545
94406
|
@font-face {
|
|
94546
94407
|
font-family: "Custom Font";
|
|
@@ -94606,6 +94467,7 @@ var GenerateImg = class extends koishi.Service {
|
|
|
94606
94467
|
</div>
|
|
94607
94468
|
|
|
94608
94469
|
<script src="${wordcloudJS}"></script>
|
|
94470
|
+
<script src="${renderFunc}"></script>
|
|
94609
94471
|
<script>
|
|
94610
94472
|
const canvas = document.getElementById('wordCloudCanvas');
|
|
94611
94473
|
const ctx = canvas.getContext('2d');
|
|
@@ -94623,38 +94485,11 @@ var GenerateImg = class extends koishi.Service {
|
|
|
94623
94485
|
|
|
94624
94486
|
const words = ${JSON.stringify(words)}
|
|
94625
94487
|
|
|
94626
|
-
|
|
94627
|
-
|
|
94628
|
-
|
|
94629
|
-
|
|
94630
|
-
|
|
94631
|
-
const maxFontSize = 80;
|
|
94632
|
-
const minFontSize = 14;
|
|
94633
|
-
|
|
94634
|
-
// 用映射函数代替 weightFactor
|
|
94635
|
-
function getWeightFactor(size) {
|
|
94636
|
-
if (maxWeight === minWeight) return maxFontSize; // 防止除0
|
|
94637
|
-
const ratio = (size - minWeight) / (maxWeight - minWeight);
|
|
94638
|
-
return minFontSize + (maxFontSize - minFontSize) * Math.pow(ratio, 0.85);
|
|
94639
|
-
}
|
|
94640
|
-
|
|
94641
|
-
WordCloud(canvas, {
|
|
94642
|
-
list: words,
|
|
94643
|
-
gridSize: Math.max(4, Math.round(5 * (cssWidth / 1024))),
|
|
94644
|
-
weightFactor: getWeightFactor,
|
|
94645
|
-
fontFamily: 'Quicksand, sans-serif',
|
|
94646
|
-
color: () => {
|
|
94647
|
-
const colors = ['#007CF0', '#00DFD8', '#7928CA', '#FF0080', '#FF4D4D', '#F9CB28'];
|
|
94648
|
-
return colors[Math.floor(Math.random() * colors.length)];
|
|
94649
|
-
},
|
|
94650
|
-
rotateRatio: 0.5,
|
|
94651
|
-
rotationSteps: 2,
|
|
94652
|
-
backgroundColor: 'transparent',
|
|
94653
|
-
drawOutOfBound: false,
|
|
94654
|
-
origin: [cssWidth / 2, cssHeight / 2], // 居中关键点
|
|
94655
|
-
// 明确告诉 wordcloud2 使用这个宽高(以 CSS 尺寸为准)
|
|
94656
|
-
width: cssWidth,
|
|
94657
|
-
height: cssHeight,
|
|
94488
|
+
renderAutoFitWordCloud(canvas, words, {
|
|
94489
|
+
maxFontSize: 40,
|
|
94490
|
+
minFontSize: 12,
|
|
94491
|
+
densityTarget: 0.3,
|
|
94492
|
+
weightExponent: 0.5
|
|
94658
94493
|
});
|
|
94659
94494
|
</script>
|
|
94660
94495
|
</body>
|
package/lib/index.mjs
CHANGED
|
@@ -801,196 +801,56 @@ var ComRegister = class {
|
|
|
801
801
|
});
|
|
802
802
|
biliCom.subcommand(".wc").action(async ({ session }) => {
|
|
803
803
|
const words = [
|
|
804
|
-
["
|
|
805
|
-
["
|
|
806
|
-
["
|
|
807
|
-
["
|
|
808
|
-
["
|
|
809
|
-
["
|
|
810
|
-
["
|
|
811
|
-
["
|
|
812
|
-
["
|
|
813
|
-
["
|
|
814
|
-
["
|
|
815
|
-
["
|
|
816
|
-
["
|
|
817
|
-
["
|
|
818
|
-
["
|
|
819
|
-
["
|
|
820
|
-
["
|
|
821
|
-
["
|
|
822
|
-
["
|
|
823
|
-
["
|
|
824
|
-
["
|
|
825
|
-
["
|
|
826
|
-
["
|
|
827
|
-
["
|
|
828
|
-
["
|
|
829
|
-
["
|
|
830
|
-
["
|
|
831
|
-
["
|
|
832
|
-
["
|
|
833
|
-
["
|
|
834
|
-
["
|
|
835
|
-
["
|
|
836
|
-
["
|
|
837
|
-
["
|
|
838
|
-
["
|
|
839
|
-
["
|
|
840
|
-
["
|
|
841
|
-
["
|
|
842
|
-
["
|
|
843
|
-
["
|
|
844
|
-
["
|
|
845
|
-
["
|
|
846
|
-
["
|
|
847
|
-
["
|
|
848
|
-
["
|
|
849
|
-
["
|
|
850
|
-
["
|
|
851
|
-
["
|
|
852
|
-
["
|
|
853
|
-
["
|
|
854
|
-
["k1q8z", 102],
|
|
855
|
-
["v7n2a", 31],
|
|
856
|
-
["b4x9p", 176],
|
|
857
|
-
["w2m5s", 61],
|
|
858
|
-
["t8j3u", 150],
|
|
859
|
-
["z5c7l", 84],
|
|
860
|
-
["h2r8y", 196],
|
|
861
|
-
["n9d1q", 44],
|
|
862
|
-
["p6s3e", 123],
|
|
863
|
-
["f8g2b", 17],
|
|
864
|
-
["m1v7k", 109],
|
|
865
|
-
["x4a9w", 72],
|
|
866
|
-
["c7t2z", 180],
|
|
867
|
-
["u5b8n", 38],
|
|
868
|
-
["e1y3h", 134],
|
|
869
|
-
["j8l6p", 56],
|
|
870
|
-
["s2q9d", 191],
|
|
871
|
-
["g7m4x", 25],
|
|
872
|
-
["a5w8c", 113],
|
|
873
|
-
["l9h2v", 68],
|
|
874
|
-
["y1k7t", 159],
|
|
875
|
-
["d8z3u", 45],
|
|
876
|
-
["q2e6j", 177],
|
|
877
|
-
["r7p1s", 80],
|
|
878
|
-
["b5n9f", 126],
|
|
879
|
-
["v1x4m", 32],
|
|
880
|
-
["t7c8w", 198],
|
|
881
|
-
["z4u2h", 54],
|
|
882
|
-
["h9y5j", 143],
|
|
883
|
-
["n2l7s", 19],
|
|
884
|
-
["p8d1g", 104],
|
|
885
|
-
["f5b3a", 67],
|
|
886
|
-
["m2v9x", 171],
|
|
887
|
-
["x8a4c", 40],
|
|
888
|
-
["c1t7u", 187],
|
|
889
|
-
["u4b2e", 28],
|
|
890
|
-
["e9y6k", 135],
|
|
891
|
-
["j2l8q", 60],
|
|
892
|
-
["s7g1m", 119],
|
|
893
|
-
["g4w5t", 76],
|
|
894
|
-
["a9z2h", 164],
|
|
895
|
-
["l1h7p", 35],
|
|
896
|
-
["y8k3n", 185],
|
|
897
|
-
["d2u9f", 22],
|
|
898
|
-
["q7e4v", 110],
|
|
899
|
-
["r5p8x", 69],
|
|
900
|
-
["b1n6c", 152],
|
|
901
|
-
["v8x2w", 48],
|
|
902
|
-
["t4c7a", 142],
|
|
903
|
-
["z7u1j", 99],
|
|
904
|
-
["k2q5z", 174],
|
|
905
|
-
["v9n8a", 37],
|
|
906
|
-
["b6x3p", 189],
|
|
907
|
-
["w1m7s", 24],
|
|
908
|
-
["t5j2u", 115],
|
|
909
|
-
["z1c8l", 63],
|
|
910
|
-
["h6r4y", 155],
|
|
911
|
-
["n3d9q", 50],
|
|
912
|
-
["p7s2e", 137],
|
|
913
|
-
["f9g1b", 81],
|
|
914
|
-
["m4v6k", 170],
|
|
915
|
-
["x1a8w", 42],
|
|
916
|
-
["c8t3z", 194],
|
|
917
|
-
["u2b7n", 26],
|
|
918
|
-
["e5y9h", 130],
|
|
919
|
-
["j9l1p", 58],
|
|
920
|
-
["s4q6d", 182],
|
|
921
|
-
["g1m8x", 33],
|
|
922
|
-
["a8w5c", 108],
|
|
923
|
-
["l3h9v", 75],
|
|
924
|
-
["y2k4t", 161],
|
|
925
|
-
["d9z1u", 46],
|
|
926
|
-
["q5e8j", 149],
|
|
927
|
-
["r2p7s", 20],
|
|
928
|
-
["b9n3f", 122],
|
|
929
|
-
["v4x6m", 65],
|
|
930
|
-
["t1c9w", 179],
|
|
931
|
-
["z8u5h", 30],
|
|
932
|
-
["h3y2j", 136],
|
|
933
|
-
["n5l8s", 52],
|
|
934
|
-
["p1d4g", 167],
|
|
935
|
-
["f6b9a", 95],
|
|
936
|
-
["m3v2x", 156],
|
|
937
|
-
["x9a5c", 43],
|
|
938
|
-
["c2t8u", 192],
|
|
939
|
-
["u7b1e", 16],
|
|
940
|
-
["e4y6k", 129],
|
|
941
|
-
["j5l3q", 78],
|
|
942
|
-
["s1g9m", 118],
|
|
943
|
-
["g8w2t", 71],
|
|
944
|
-
["a3z7h", 173],
|
|
945
|
-
["l6h1p", 36],
|
|
946
|
-
["y9k5n", 184],
|
|
947
|
-
["d1u8f", 15],
|
|
948
|
-
["q8e3v", 111],
|
|
949
|
-
["r4p6x", 64],
|
|
950
|
-
["b2n7c", 151],
|
|
951
|
-
["v5x1w", 47],
|
|
952
|
-
["t8c4a", 140],
|
|
953
|
-
["z3u9j", 98],
|
|
954
|
-
["k7q2z", 176],
|
|
955
|
-
["v1n5a", 55],
|
|
956
|
-
["b8x6p", 195],
|
|
957
|
-
["w3m1s", 14],
|
|
958
|
-
["t6j9u", 116],
|
|
959
|
-
["z2c5l", 61],
|
|
960
|
-
["h7r3y", 153],
|
|
961
|
-
["n4d8q", 51],
|
|
962
|
-
["p2s7e", 139],
|
|
963
|
-
["f7g5b", 82],
|
|
964
|
-
["m9v1k", 169],
|
|
965
|
-
["x5a3w", 38],
|
|
966
|
-
["c9t6z", 197],
|
|
967
|
-
["u3b8n", 17],
|
|
968
|
-
["e6y2h", 131],
|
|
969
|
-
["j7l5p", 59],
|
|
970
|
-
["s3q8d", 181],
|
|
971
|
-
["g2m4x", 34],
|
|
972
|
-
["a6w9c", 107],
|
|
973
|
-
["l8h2v", 74],
|
|
974
|
-
["y4k7t", 162],
|
|
975
|
-
["d6z5u", 49],
|
|
976
|
-
["q3e1j", 148],
|
|
977
|
-
["r9p2s", 21],
|
|
978
|
-
["b4n8f", 121],
|
|
979
|
-
["v7x5m", 68],
|
|
980
|
-
["t2c1w", 178],
|
|
981
|
-
["z5u3h", 31],
|
|
982
|
-
["h8y6j", 133],
|
|
983
|
-
["n1l4s", 57],
|
|
984
|
-
["p5d7g", 166],
|
|
985
|
-
["f3b2a", 96],
|
|
986
|
-
["m6v8x", 158],
|
|
987
|
-
["x2a9c", 45],
|
|
988
|
-
["c5t1u", 191],
|
|
989
|
-
["u8b4e", 19],
|
|
990
|
-
["e3y7k", 128],
|
|
991
|
-
["j6l2q", 79],
|
|
992
|
-
["s9g5m", 114],
|
|
993
|
-
["g5w3t", 73]
|
|
804
|
+
["弹幕护体", 77],
|
|
805
|
+
["笑死", 30],
|
|
806
|
+
["泪目", 45],
|
|
807
|
+
["加油", 70],
|
|
808
|
+
["???", 80],
|
|
809
|
+
["我可以", 66],
|
|
810
|
+
["无语", 55],
|
|
811
|
+
["梦开始的地方", 1],
|
|
812
|
+
["太真实了", 8],
|
|
813
|
+
["我哭死", 1],
|
|
814
|
+
["人呢", 2],
|
|
815
|
+
["有点意思", 4],
|
|
816
|
+
["妙啊", 4],
|
|
817
|
+
["这波啊", 11],
|
|
818
|
+
["懂了", 6],
|
|
819
|
+
["破防了", 65],
|
|
820
|
+
["蚌埠住了", 92],
|
|
821
|
+
["草", 100],
|
|
822
|
+
["针不戳", 68],
|
|
823
|
+
["yyds", 50],
|
|
824
|
+
["DNA动了", 58],
|
|
825
|
+
["猝不及防", 40],
|
|
826
|
+
["建议加精", 15],
|
|
827
|
+
["保护", 22],
|
|
828
|
+
["害怕", 18],
|
|
829
|
+
["就这?", 99],
|
|
830
|
+
["2333", 20],
|
|
831
|
+
["公开处刑", 35],
|
|
832
|
+
["血压上来了", 45],
|
|
833
|
+
["整不会了", 32],
|
|
834
|
+
["见证历史", 88],
|
|
835
|
+
["下次一定", 65],
|
|
836
|
+
["奥利给", 56],
|
|
837
|
+
["求更新", 18],
|
|
838
|
+
["真实", 20],
|
|
839
|
+
["好活当赏", 25],
|
|
840
|
+
["泪,冲了出来", 68],
|
|
841
|
+
["刻进DNA", 70],
|
|
842
|
+
["我直接好家伙", 55],
|
|
843
|
+
["夺笋啊", 40],
|
|
844
|
+
["歪歪滴艾斯", 1],
|
|
845
|
+
["典中典", 5],
|
|
846
|
+
["麻中麻", 3],
|
|
847
|
+
["绷不住了", 8],
|
|
848
|
+
["逆天", 95],
|
|
849
|
+
["寄", 65],
|
|
850
|
+
["孝", 20],
|
|
851
|
+
["乐", 101],
|
|
852
|
+
["急急急", 3],
|
|
853
|
+
["典", 5]
|
|
994
854
|
];
|
|
995
855
|
await session.send(/* @__PURE__ */ jsx("message", { children: h.image(await this.ctx.gi.generateWordCloudImg(words, "词云测试"), "image/jpg") }));
|
|
996
856
|
});
|
|
@@ -1438,12 +1298,12 @@ var ComRegister = class {
|
|
|
1438
1298
|
const liveMsgObj = this.liveMsgManager.get(uid);
|
|
1439
1299
|
const sendDanmakuWordCloud = async () => {
|
|
1440
1300
|
this.logger.info("开始制作弹幕词云");
|
|
1441
|
-
this.logger.info("正在获取前
|
|
1442
|
-
const
|
|
1443
|
-
this.logger.info("弹幕词云前
|
|
1444
|
-
this.logger.info(
|
|
1301
|
+
this.logger.info("正在获取前50热词");
|
|
1302
|
+
const top50Words = Object.entries(danmakuWeightRecord).sort((a$1, b$2) => b$2[1] - a$1[1]).slice(0, 50);
|
|
1303
|
+
this.logger.info("弹幕词云前50词及权重:");
|
|
1304
|
+
this.logger.info(top50Words);
|
|
1445
1305
|
this.logger.info("正在准备生成弹幕词云");
|
|
1446
|
-
const buffer = await this.ctx.gi.generateWordCloudImg(
|
|
1306
|
+
const buffer = await this.ctx.gi.generateWordCloudImg(top50Words, masterInfo.username);
|
|
1447
1307
|
this.logger.info("弹幕词云生成完成,正在准备发送词云图片");
|
|
1448
1308
|
await this.broadcastToTargets(uid, h.image(buffer, "image/jpeg"), PushType.Live);
|
|
1449
1309
|
};
|
|
@@ -84387,6 +84247,7 @@ var require_tar_fs = __commonJS$1({ "node_modules/tar-fs/index.js"(exports) {
|
|
|
84387
84247
|
const now = /* @__PURE__ */ new Date();
|
|
84388
84248
|
const umask = typeof opts.umask === "number" ? ~opts.umask : ~processUmask();
|
|
84389
84249
|
const strict = opts.strict !== false;
|
|
84250
|
+
const validateSymLinks = opts.validateSymlinks !== false;
|
|
84390
84251
|
let map = opts.map || noop;
|
|
84391
84252
|
let dmode = typeof opts.dmode === "number" ? opts.dmode : 0;
|
|
84392
84253
|
let fmode = typeof opts.fmode === "number" ? opts.fmode : 0;
|
|
@@ -84454,7 +84315,7 @@ var require_tar_fs = __commonJS$1({ "node_modules/tar-fs/index.js"(exports) {
|
|
|
84454
84315
|
if (win32$1) return next();
|
|
84455
84316
|
xfs.unlink(name$3, function() {
|
|
84456
84317
|
const dst = path$3.resolve(path$3.dirname(name$3), header.linkname);
|
|
84457
|
-
if (!inCwd(dst)) return next(/* @__PURE__ */ new Error(name$3 + " is not a valid symlink"));
|
|
84318
|
+
if (!inCwd(dst) && validateSymLinks) return next(/* @__PURE__ */ new Error(name$3 + " is not a valid symlink"));
|
|
84458
84319
|
xfs.symlink(header.linkname, name$3, stat);
|
|
84459
84320
|
});
|
|
84460
84321
|
}
|
|
@@ -94535,6 +94396,7 @@ var GenerateImg = class extends Service {
|
|
|
94535
94396
|
async generateWordCloudImg(words, masterName) {
|
|
94536
94397
|
const fontURL = pathToFileURL(resolve$1(__dirname, "font/HYZhengYuan-75W.ttf"));
|
|
94537
94398
|
const wordcloudJS = pathToFileURL(resolve$1(__dirname, "static/wordcloud2.min.js"));
|
|
94399
|
+
const renderFunc = pathToFileURL(resolve$1(__dirname, "static/render.js"));
|
|
94538
94400
|
const html = `
|
|
94539
94401
|
<!DOCTYPE html>
|
|
94540
94402
|
<html lang="zh-CN">
|
|
@@ -94542,7 +94404,6 @@ var GenerateImg = class extends Service {
|
|
|
94542
94404
|
<head>
|
|
94543
94405
|
<meta charset="UTF-8">
|
|
94544
94406
|
<title>高清词云展示</title>
|
|
94545
|
-
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@500&display=swap" rel="stylesheet">
|
|
94546
94407
|
<style>
|
|
94547
94408
|
@font-face {
|
|
94548
94409
|
font-family: "Custom Font";
|
|
@@ -94608,6 +94469,7 @@ var GenerateImg = class extends Service {
|
|
|
94608
94469
|
</div>
|
|
94609
94470
|
|
|
94610
94471
|
<script src="${wordcloudJS}"></script>
|
|
94472
|
+
<script src="${renderFunc}"></script>
|
|
94611
94473
|
<script>
|
|
94612
94474
|
const canvas = document.getElementById('wordCloudCanvas');
|
|
94613
94475
|
const ctx = canvas.getContext('2d');
|
|
@@ -94625,38 +94487,11 @@ var GenerateImg = class extends Service {
|
|
|
94625
94487
|
|
|
94626
94488
|
const words = ${JSON.stringify(words)}
|
|
94627
94489
|
|
|
94628
|
-
|
|
94629
|
-
|
|
94630
|
-
|
|
94631
|
-
|
|
94632
|
-
|
|
94633
|
-
const maxFontSize = 80;
|
|
94634
|
-
const minFontSize = 14;
|
|
94635
|
-
|
|
94636
|
-
// 用映射函数代替 weightFactor
|
|
94637
|
-
function getWeightFactor(size) {
|
|
94638
|
-
if (maxWeight === minWeight) return maxFontSize; // 防止除0
|
|
94639
|
-
const ratio = (size - minWeight) / (maxWeight - minWeight);
|
|
94640
|
-
return minFontSize + (maxFontSize - minFontSize) * Math.pow(ratio, 0.85);
|
|
94641
|
-
}
|
|
94642
|
-
|
|
94643
|
-
WordCloud(canvas, {
|
|
94644
|
-
list: words,
|
|
94645
|
-
gridSize: Math.max(4, Math.round(5 * (cssWidth / 1024))),
|
|
94646
|
-
weightFactor: getWeightFactor,
|
|
94647
|
-
fontFamily: 'Quicksand, sans-serif',
|
|
94648
|
-
color: () => {
|
|
94649
|
-
const colors = ['#007CF0', '#00DFD8', '#7928CA', '#FF0080', '#FF4D4D', '#F9CB28'];
|
|
94650
|
-
return colors[Math.floor(Math.random() * colors.length)];
|
|
94651
|
-
},
|
|
94652
|
-
rotateRatio: 0.5,
|
|
94653
|
-
rotationSteps: 2,
|
|
94654
|
-
backgroundColor: 'transparent',
|
|
94655
|
-
drawOutOfBound: false,
|
|
94656
|
-
origin: [cssWidth / 2, cssHeight / 2], // 居中关键点
|
|
94657
|
-
// 明确告诉 wordcloud2 使用这个宽高(以 CSS 尺寸为准)
|
|
94658
|
-
width: cssWidth,
|
|
94659
|
-
height: cssHeight,
|
|
94490
|
+
renderAutoFitWordCloud(canvas, words, {
|
|
94491
|
+
maxFontSize: 40,
|
|
94492
|
+
minFontSize: 12,
|
|
94493
|
+
densityTarget: 0.3,
|
|
94494
|
+
weightExponent: 0.5
|
|
94660
94495
|
});
|
|
94661
94496
|
</script>
|
|
94662
94497
|
</body>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 自动适配的词云渲染函数,直到填满画布
|
|
3
|
+
* @param {HTMLCanvasElement} canvas - canvas 元素
|
|
4
|
+
* @param {Array<[string, number]>} words - 词数组 [['哈哈', 20], ['666', 10]]
|
|
5
|
+
* @param {Object} options - 选项
|
|
6
|
+
*/
|
|
7
|
+
function renderAutoFitWordCloud(canvas, words, options = {}) {
|
|
8
|
+
const ctx = canvas.getContext("2d");
|
|
9
|
+
const style = getComputedStyle(canvas);
|
|
10
|
+
const cssWidth = parseInt(style.width);
|
|
11
|
+
const cssHeight = parseInt(style.height);
|
|
12
|
+
const ratio = window.devicePixelRatio || 1;
|
|
13
|
+
|
|
14
|
+
// 设置高清分辨率
|
|
15
|
+
canvas.width = cssWidth * ratio;
|
|
16
|
+
canvas.height = cssHeight * ratio;
|
|
17
|
+
ctx.scale(ratio, ratio);
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
fontFamily = 'sans-serif',
|
|
21
|
+
maxFontSize = 72,
|
|
22
|
+
minFontSize = 12,
|
|
23
|
+
densityTarget = 0.25,
|
|
24
|
+
weightExponent = 0.5,
|
|
25
|
+
rotationSteps = 2,
|
|
26
|
+
rotateRatio = 0.4,
|
|
27
|
+
color = () => ['#007CF0', '#00DFD8', '#7928CA', '#FF0080', '#FF4D4D', '#F9CB28'][Math.floor(Math.random() * 6)],
|
|
28
|
+
backgroundColor = 'transparent'
|
|
29
|
+
} = options;
|
|
30
|
+
|
|
31
|
+
const weightFactor = createDynamicWeightFactor(words, cssWidth, cssHeight, {
|
|
32
|
+
maxFontSize,
|
|
33
|
+
minFontSize,
|
|
34
|
+
densityTarget,
|
|
35
|
+
weightExponent
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
WordCloud(canvas, {
|
|
39
|
+
list: words,
|
|
40
|
+
gridSize: Math.max(2, Math.floor(cssWidth / 100)), // 自动调整 gridSize
|
|
41
|
+
weightFactor,
|
|
42
|
+
fontFamily,
|
|
43
|
+
color,
|
|
44
|
+
rotateRatio,
|
|
45
|
+
rotationSteps,
|
|
46
|
+
backgroundColor,
|
|
47
|
+
drawOutOfBound: false,
|
|
48
|
+
origin: [cssWidth / 2, cssHeight / 2],
|
|
49
|
+
width: cssWidth,
|
|
50
|
+
height: cssHeight,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* function createDynamicWeightFactor(words, width, height, {
|
|
55
|
+
maxFontSize = 72,
|
|
56
|
+
minFontSize = 12,
|
|
57
|
+
densityTarget = 0.25
|
|
58
|
+
} = {}) {
|
|
59
|
+
const weights = words.map(w => w[1]);
|
|
60
|
+
const maxWeight = Math.max(...weights);
|
|
61
|
+
const minWeight = Math.min(...weights);
|
|
62
|
+
const range = maxWeight - minWeight || 1;
|
|
63
|
+
|
|
64
|
+
// 移除基于词数的自动缩放
|
|
65
|
+
const realMax = maxFontSize;
|
|
66
|
+
const realMin = minFontSize;
|
|
67
|
+
|
|
68
|
+
// 改为基于画布面积的密度控制
|
|
69
|
+
const areaPerWord = (width * height * densityTarget) / words.length;
|
|
70
|
+
const sizeScale = Math.min(1, Math.sqrt(areaPerWord / 500)); // 500是可调基准值
|
|
71
|
+
|
|
72
|
+
return function weightFactor(weight) {
|
|
73
|
+
const norm = (weight - minWeight) / range;
|
|
74
|
+
// 应用三次方曲线让大小差异更明显
|
|
75
|
+
const sizeRatio = Math.pow(norm, 0.33);
|
|
76
|
+
return realMin + (realMax - realMin) * sizeRatio * sizeScale;
|
|
77
|
+
};
|
|
78
|
+
} */
|
|
79
|
+
|
|
80
|
+
function createDynamicWeightFactor(words, width, height, {
|
|
81
|
+
maxFontSize = 72,
|
|
82
|
+
minFontSize = 12,
|
|
83
|
+
densityTarget = 0.25,
|
|
84
|
+
weightExponent = 0.5 // 新增权重指数参数
|
|
85
|
+
} = {}) {
|
|
86
|
+
const weights = words.map(w => w[1]);
|
|
87
|
+
const maxWeight = Math.max(...weights);
|
|
88
|
+
const minWeight = Math.min(...weights);
|
|
89
|
+
const range = Math.max(1, maxWeight - minWeight); // 确保不为0
|
|
90
|
+
|
|
91
|
+
// 计算权重转换曲线
|
|
92
|
+
const weightCurve = (weight) => {
|
|
93
|
+
const normalized = (weight - minWeight) / range;
|
|
94
|
+
// 使用指数曲线放大差异
|
|
95
|
+
return Math.pow(normalized, weightExponent);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// 计算动态缩放比例(基于画布面积和词数)
|
|
99
|
+
const areaScale = Math.sqrt((width * height * densityTarget) / words.length) / 20;
|
|
100
|
+
const sizeScale = Math.min(1, Math.max(0.3, areaScale)); // 限制在0.3-1之间
|
|
101
|
+
|
|
102
|
+
return function (weight) {
|
|
103
|
+
const curveValue = weightCurve(weight);
|
|
104
|
+
// 应用非线性放大
|
|
105
|
+
return minFontSize + (maxFontSize - minFontSize) * curveValue * sizeScale;
|
|
106
|
+
};
|
|
107
|
+
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -306,6 +306,7 @@ uid为必填参数,为要推送的UP主的UID,index为可选参数,为要
|
|
|
306
306
|
> - ver 3.2.9-alpha.3 修复:词云生成空白
|
|
307
307
|
> - ver 3.2.9-alpha.4 修复:弹幕词云bug `Error: 生成图片失败!错误: TimeoutError: Navigation timeout of 30000 ms exceeded`
|
|
308
308
|
> - ver 3.2.9-rc.0 优化:弹幕词云生成效果、选项 `pushTime` 设置为0时可关闭该功能; 新增:选项 `wordcloud` 可选择在直播结束后是否生成弹幕词云
|
|
309
|
+
> - ver 3.2.9-rc.1 优化:弹幕词云生成效果;
|
|
309
310
|
|
|
310
311
|
## 交流群
|
|
311
312
|
|