diff --git a/Source/Game/Chat/Channels/ChannelManager.cs b/Source/Game/Chat/Channels/ChannelManager.cs index 924e51df9..c18a74269 100644 --- a/Source/Game/Chat/Channels/ChannelManager.cs +++ b/Source/Game/Chat/Channels/ChannelManager.cs @@ -44,7 +44,7 @@ namespace Game.Chat uint oldMSTime = Time.GetMSTime(); uint days = WorldConfig.GetUIntValue(WorldCfg.PreserveCustomChannelDuration); if (days != 0) - { + { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_OLD_CHANNELS); stmt.AddValue(0, days * Time.Day); DB.Characters.Execute(stmt); @@ -86,7 +86,7 @@ namespace Game.Chat } while (result.NextRow()); foreach (var (name, team) in toDelete) - { + { PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_CHANNEL); stmt.AddValue(0, name); stmt.AddValue(1, (uint)team); @@ -165,7 +165,7 @@ namespace Game.Chat { return _customChannels.LookupByKey(name.ToLower()); } - + public Channel GetChannel(uint channelId, string name, Player player, bool notify = true, AreaTableRecord zoneEntry = null) { Channel result = null; diff --git a/Source/Game/Handlers/ChannelHandler.cs b/Source/Game/Handlers/ChannelHandler.cs index a6aede56f..a6dbad389 100644 --- a/Source/Game/Handlers/ChannelHandler.cs +++ b/Source/Game/Handlers/ChannelHandler.cs @@ -41,51 +41,45 @@ namespace Game return; } - if (packet.ChannelName.IsEmpty() || char.IsDigit(packet.ChannelName[0])) - { - ChannelNotify channelNotify = new(); - channelNotify.Type = ChatNotify.InvalidNameNotice; - channelNotify.Channel = packet.ChannelName; - SendPacket(channelNotify); - return; - } - - if (packet.Password.Length > 127) - { - Log.outError(LogFilter.Network, $"Player {GetPlayer().GetGUID()} tried to create a channel with a password more than 127 characters long - blocked"); - return; - } - ChannelManager cMgr = ChannelManager.ForTeam(GetPlayer().GetTeam()); - if (cMgr != null) - { - if (packet.ChatChannelId != 0) + if (cMgr == null) + return; + + if (packet.ChatChannelId != 0) + { // system channel + Channel channel = cMgr.GetSystemChannel((uint)packet.ChatChannelId, zone); + if (channel != null) + channel.JoinChannel(GetPlayer()); + } + else + { // custom channel + if (packet.ChannelName.IsEmpty() || Char.IsDigit(packet.ChannelName[0])) { - // system channel - Channel channel = cMgr.GetSystemChannel((uint)packet.ChatChannelId, zone); - if (channel != null) - channel.JoinChannel(GetPlayer()); + ChannelNotify channelNotify = new(); + channelNotify.Type = ChatNotify.InvalidNameNotice; + channelNotify.Channel = packet.ChannelName; + SendPacket(channelNotify); + return; } + + if (packet.Password.Length > 127) + { + Log.outError(LogFilter.Network, $"Player {GetPlayer().GetGUID()} tried to create a channel with a password more than {127} characters long - blocked"); + return; + } + if (!DisallowHyperlinksAndMaybeKick(packet.ChannelName)) + return; + + Channel channel = cMgr.GetCustomChannel(packet.ChannelName); + if (channel != null) + channel.JoinChannel(GetPlayer(), packet.Password); else { - // custom channel - if (packet.ChannelName.Length > 31) - { - Log.outError(LogFilter.Network, $"Player {GetPlayer().GetGUID()} tried to create a channel with a name more than 31 characters long - blocked"); - return; - } - - Channel channel = cMgr.GetCustomChannel(packet.ChannelName); + channel = cMgr.CreateCustomChannel(packet.ChannelName); if (channel != null) - channel.JoinChannel(GetPlayer(), packet.Password); - else { - channel = cMgr.CreateCustomChannel(packet.ChannelName); - if (channel != null) - { - channel.SetPassword(packet.Password); - channel.JoinChannel(GetPlayer(), packet.Password); - } + channel.SetPassword(packet.Password); + channel.JoinChannel(GetPlayer(), packet.Password); } } }