Skip to content

Commit

Permalink
fix server reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Controllerdestiny committed Dec 20, 2024
1 parent 5bbce93 commit 009ac7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Lagrange.XocMat/Event/TerrariaMsgReceiveHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Lagrange.XocMat.Internal.Socket.PlayerMessage;
using Lagrange.XocMat.Internal.Socket.ServerMessage;
using Lagrange.XocMat.Net;
using Lagrange.XocMat.Utility;
using Microsoft.Extensions.Logging;
using ProtoBuf;
using System.Reactive.Linq;
Expand Down Expand Up @@ -253,6 +254,17 @@ internal async void GroupMessageForwardAdapter(BotContext bot, GroupMessageEvent
{
return;
}
var file = args.Chain.GetFile();
if (file != null && file.FileSize < 1024 * 1024 * 30)
{
foreach(var setting in XocMatSetting.Instance.Servers)
{
if (file.FileUrl != null && setting != null && setting.Groups.Contains(Convert.ToUInt32(args.Chain.GroupUin)) && setting.WaitFile != null)
{
setting.WaitFile.SetResult(await HttpUtils.HttpGetByte(file.FileUrl));
}
}
}
var text = args.Chain.GetText();
if (string.IsNullOrEmpty(text))
return;
Expand Down
2 changes: 1 addition & 1 deletion Lagrange.XocMat/Extensions/MessageChainExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public static string GetText(this MessageChain chain)

public static FileEntity? GetFile(this MessageChain chain)
{
return (FileEntity)chain.Where(c => c is FileEntity).First();
return (FileEntity?)chain.Where(c => c is FileEntity).FirstOrDefault();
}
}

0 comments on commit 009ac7c

Please sign in to comment.