diff --git a/BiliApi.Net b/BiliApi.Net index bf943fa..c0b3597 160000 --- a/BiliApi.Net +++ b/BiliApi.Net @@ -1 +1 @@ -Subproject commit bf943fa1a325112e75e3e72b0cbb5be90e9d1fe4 +Subproject commit c0b35979e69d00cbcf882e18e3fbac4a86f2349b diff --git a/BiliveDanmakuAgent b/BiliveDanmakuAgent index 6e51516..7621a1f 160000 --- a/BiliveDanmakuAgent +++ b/BiliveDanmakuAgent @@ -1 +1 @@ -Subproject commit 6e51516ba3fe765078f3c4187bd7023e50700d34 +Subproject commit 7621a1fb45b69b4e088574a05389a800206c6a00 diff --git a/OpenDanmaki/OpenDanmaki.cs b/OpenDanmaki/OpenDanmaki.cs index c4279a0..b63ee64 100644 --- a/OpenDanmaki/OpenDanmaki.cs +++ b/OpenDanmaki/OpenDanmaki.cs @@ -22,6 +22,8 @@ public class OpenDanmaki public DanmakuApi BiliDanmaku; public PluginLoader Pluginloader; public TmpResourceProvider TmpResourceProvider; + public GiftResourcesProvider GiftResourcesProvider; + public static Config Config { get; set; } /// /// 在弹幕事件(包含sc、礼物等)接收后、被处理前触发 @@ -64,15 +66,19 @@ public OpenDanmaki(int liveroomid, string logincookie = "", string host = "local BiliDanmaku = new DanmakuApi(liveroomid, logincookie); Pluginloader = new PluginLoader(this); TmpResourceProvider = new TmpResourceProvider("http://" + host + ":" + port + "/attachments/"); + GiftResourcesProvider = new GiftResourcesProvider("http://" + host + ":" + port + "/"); BiliDanmaku.DanmakuMsgReceivedEvent += BiliDanmaku_DanmakuMsgReceivedEvent; BiliDanmaku.CommentReceived += BiliDanmaku_CommentReceived; BiliDanmaku.Superchat += BiliDanmaku_Superchat; BiliDanmaku.Gift += BiliDanmaku_Gift; BiliDanmaku.GuardBuy += BiliDanmaku_GuardBuy; } - - public OpenDanmaki(Config config) : this(config.TargetRoomId, config.BiliCookie, config.LocalHostname, config.LocalPort) { } + + public OpenDanmaki(Config config) : this(config.TargetRoomId, config.BiliCookie, config.LocalHostname, config.LocalPort) + { + Config = config; + } private void BiliDanmaku_DanmakuMsgReceivedEvent(object sender, DanmakuReceivedEventArgs e) { @@ -135,12 +141,17 @@ private void BiliDanmaku_CommentReceived(object sender, BiliveDanmakuAgent.Model public async Task StartAsync() { + Directory.CreateDirectory("./plugins"); + Directory.CreateDirectory("./visual_assets/emoji"); + Directory.CreateDirectory("./visual_assets/gifts"); await Server.StartAsync(); await BiliDanmaku.ConnectAsync(); var ver = Assembly.GetExecutingAssembly().GetName().Version; + logger.Debug("OpenDanmaki is preloading gift resources list..."); + var cnt = GiftResourcesProvider.LoadGiftResourcesList(Config); + logger.Debug("Loaded " + cnt + " gift resource url."); logger.Info("OpenDanmaki " + ver.ToString() + " loaded."); logger.Info("Start loading plugins..."); - Directory.CreateDirectory("plugins"); Directory.GetFiles("plugins").ToList().ForEach(x => { if (x.ToLower().EndsWith(".odp.dll")) diff --git a/OpenDanmaki/visual_assets/kboard/kboard.html b/OpenDanmaki/visual_assets/kboard/kboard.html index 35a0db8..3473852 100644 --- a/OpenDanmaki/visual_assets/kboard/kboard.html +++ b/OpenDanmaki/visual_assets/kboard/kboard.html @@ -73,7 +73,7 @@ } } - .chat-message img { + .avatar { width: 50px; height: 50px; border-radius: 50%; @@ -136,6 +136,7 @@ message.className = 'chat-message'; var img = document.createElement('img'); + img.classList.add('avatar'); img.src = avatar; // Replace with actual avatar URL var bubble = document.createElement('div'); @@ -159,8 +160,10 @@ var text = document.createElement('div'); - text.innerHTML = messagetxt.toString().replace(/\[img:(.*?)\]/g, function (match, url) { - return ''; + text.innerHTML = messagetxt.toString().replace(/\[emoj:(.*?)\]/g, function (match, url) { + return ''; + }).replace(/\[img:(.*?)\]/g, function (match, url) { + return ''; }); // Replace [url] with img element bubble.appendChild(name); @@ -187,8 +190,7 @@ clearTimeout(pinnedMessageTimeout); clearInterval(pinnedMessageInterval); chatContainer.removeEventListener('scroll', pinnedMessageListener); - pinnedMessage.element.style.position = ''; - pinnedMessage.element.remove(); + pinnedchatContainer.innerHTML = ""; } // Pin the new message @@ -214,13 +216,13 @@ chatContainer.addEventListener('scroll', listener); } - // window.setInterval(function () { - // var pri = Math.random() * 100; - // addPinnedMessage('Name', "表情[img:https://g.csdnimg.cn/static/face/emoji/010.png]测试 优先级" + pri, 'https://i2.hdslb.com/bfs/face/8e80dfc2cc59b1d3d6c48895666aa28b9dd323ae.jpg@150w_150h.jpg', ["Saab"], pri); - // }, 500) - // window.setInterval(function () { - // addMessage('Name', "表情[img:https://g.csdnimg.cn/static/face/emoji/010.png]测试" + Math.random(), 'https://i2.hdslb.com/bfs/face/8e80dfc2cc59b1d3d6c48895666aa28b9dd323ae.jpg@150w_150h.jpg', ["Saab"]); - // }, 300) + //window.setInterval(function () { + // var pri = Math.random() * 100; + // addPinnedMessage('Name', "表情[img:https://g.csdnimg.cn/static/face/emoji/010.png]测试 优先级" + pri, 'https://i2.hdslb.com/bfs/face/8e80dfc2cc59b1d3d6c48895666aa28b9dd323ae.jpg@150w_150h.jpg', ["Saab"], pri); + //}, 500) + //window.setInterval(function () { + // addMessage('Name', "表情[img:https://g.csdnimg.cn/static/face/emoji/010.png]测试" + Math.random(), 'https://i2.hdslb.com/bfs/face/8e80dfc2cc59b1d3d6c48895666aa28b9dd323ae.jpg@150w_150h.jpg', ["Saab"]); + //}, 300)