Skip to content

Commit

Permalink
更新参考样式模板
Browse files Browse the repository at this point in the history
  • Loading branch information
developer-ken committed Jan 27, 2024
1 parent 33fe391 commit 5e02c53
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 17 deletions.
2 changes: 1 addition & 1 deletion BiliApi.Net
Submodule BiliApi.Net updated 2 files
+0 −1 BiliSession.cs
+2 −0 BiliUser.cs
2 changes: 1 addition & 1 deletion BiliveDanmakuAgent
17 changes: 14 additions & 3 deletions OpenDanmaki/OpenDanmaki.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

/// <summary>
/// 在弹幕事件(包含sc、礼物等)接收后、被处理前触发
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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"))
Expand Down
44 changes: 32 additions & 12 deletions OpenDanmaki/visual_assets/kboard/kboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
}
}

.chat-message img {
.avatar {
width: 50px;
height: 50px;
border-radius: 50%;
Expand Down Expand Up @@ -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');
Expand All @@ -159,8 +160,10 @@

var text = document.createElement('div');

text.innerHTML = messagetxt.toString().replace(/\[img:(.*?)\]/g, function (match, url) {
return '<img src="' + url + '" style="width: 1.5em; height: 1.5em;">';
text.innerHTML = messagetxt.toString().replace(/\[emoj:(.*?)\]/g, function (match, url) {
return '<img src="' + url + '" style="height: 1.5em;">';
}).replace(/\[img:(.*?)\]/g, function (match, url) {
return '<img src="' + url + '" style="height: 45px;">';
}); // Replace [url] with img element

bubble.appendChild(name);
Expand All @@ -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
Expand All @@ -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)
</script>

<script>
Expand All @@ -239,6 +241,24 @@
case 'pinned':
addPinnedMessage(message.name, message.content, message.avatar, message.tags, message.priority);
break;
case 'gift':
addMessage(message.name, "送出 [emoj:" + message.img_url + "]<u>" + message.gift_name + "</u> x" + message.gift_count, message.avatar, message.tags);
break;
case 'crew':
var typename = "未知";
switch (message.ctype) {
case 1:
typename = "总督";
break;
case 2:
typename = "提督";
break;
case 3:
typename = "舰长";
break;
}
addPinnedMessage(message.name, "充值 <u>" + typename + "</u> x" + message.gift_count + "月", message.avatar, message.tags, (4 - message.ctype) * 10);
break;
}
};

Expand Down

0 comments on commit 5e02c53

Please sign in to comment.