mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-12 17:44:42 +01:00
50 lines
2.0 KiB
C#
50 lines
2.0 KiB
C#
using Common.Database;
|
|
using Common;
|
|
using Common.Resources.Proto;
|
|
|
|
namespace PemukulPaku.GameServer.Game.Chatrooms
|
|
{
|
|
public static class PrivateChatManager
|
|
{
|
|
public static void OnSendChatMsg(Session session, SendChatMsgNotify chatMsgNotify)
|
|
{
|
|
ChatMsg chatMsg = chatMsgNotify.ChatMsg;
|
|
string? StringMsg = chatMsg.Content.Items.Where(item => item.MsgStr != null).FirstOrDefault()?.MsgStr;
|
|
if (StringMsg != null)
|
|
{
|
|
chatMsg.CheckResult = new()
|
|
{
|
|
ShieldType = 0,
|
|
NumberCheck = 0,
|
|
RewriteText = StringMsg
|
|
};
|
|
chatMsg.Msg = StringMsg;
|
|
}
|
|
UserScheme User = session.Player.User;
|
|
chatMsg.Uid = User.Uid;
|
|
chatMsg.Nickname = User.Nick;
|
|
chatMsg.Time = (uint)Global.GetUnixInSeconds();
|
|
chatMsg.AvatarId = (uint)User.AssistantAvatarId;
|
|
chatMsg.DressId = session.Player.AvatarList.Where(avatar => avatar.AvatarId == User.AssistantAvatarId).First().DressId;
|
|
chatMsg.FrameId = User.FrameId < 200001 ? 200001 : (uint)User.FrameId;
|
|
chatMsg.CustomHeadId = (uint)User.CustomHeadId;
|
|
|
|
foreach (uint targetUid in chatMsgNotify.TargetUidLists)
|
|
{
|
|
SendPrivateMessage(session, targetUid, chatMsg);
|
|
}
|
|
}
|
|
|
|
public static void SendPrivateMessage(Session session, uint targetUid, ChatMsg chatMsg)
|
|
{
|
|
PrivateMessageScheme privateMessage = PrivateMessage.Create(session.Player.User.Uid, targetUid, chatMsg);
|
|
Session? targetSession = Session.FromUid(targetUid);
|
|
RecvChatMsgNotify notify = new() { };
|
|
notify.ChatMsgLists.Add(privateMessage.Msg);
|
|
|
|
session.Send(Packet.FromProto(notify, CmdId.RecvChatMsgNotify));
|
|
targetSession?.Send(Packet.FromProto(notify, CmdId.RecvChatMsgNotify));
|
|
}
|
|
}
|
|
}
|