public virtual bool DispatchChatMessage(ChatChannelEnum channel, string message, CharacterEntity whispedCharacter = null)
{
var channelData = m_chatByChannel[channel];
if (channelData == null)
return false;
if (channel != ChatChannelEnum.CHANNEL_PRIVATE_RECEIVE)
{
if (message.Equals(channelData.LastMessage, StringComparison.OrdinalIgnoreCase))
{
Dispatch(WorldMessage.IM_ERROR_MESSAGE(InformationEnum.ERROR_CHAT_SAME_MESSAGE));
return false;
}
channelData.LastMessage = message;
if (UpdateTime < channelData.NextTime)
{
Dispatch(WorldMessage.IM_INFO_MESSAGE(InformationEnum.INFO_CHAT_SPAM_RESTRICTED, Math.Ceiling((channelData.NextTime - UpdateTime) * 0.001)));
return false;
}
var delay = WorldConfig.CHAT_RESTRICTED_DELAY.ContainsKey(channel) ? WorldConfig.CHAT_RESTRICTED_DELAY[channel] : 0;
channelData.NextTime = UpdateTime + delay;
}
var dispatcher = channelData.Dispatcher();
if (dispatcher != null)
{
switch (channel)
{
case ChatChannelEnum.CHANNEL_PRIVATE_SEND:
case ChatChannelEnum.CHANNEL_PRIVATE_RECEIVE:
dispatcher(WorldMessage.CHAT_MESSAGE(channel, whispedCharacter.Id, whispedCharacter.Name, message));
break;
default:
dispatcher(WorldMessage.CHAT_MESSAGE(channel, Id, Name, message));
break;
}
}
return true;
}