mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-14 19:34:37 +01:00
unstable whisper, now you can dm your friend(if you have any lol)
This commit is contained in:
49
GameServer/Game/Chatrooms/PrivateChatManager.cs
Normal file
49
GameServer/Game/Chatrooms/PrivateChatManager.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user