66 std::string::size_type pos = msg.find_first_of(
"\n\r");
69 else if (pos != std::string::npos)
77 TC_LOG_ERROR(
"network",
"Player {} {} sent a message containing invalid character {} - blocked", player->
GetName(),
86 auto end = std::unique(msg.begin(), msg.end(), [](
char c1,
char c2) { return (c1 ==
' ') && (c2 ==
' '); });
87 msg.erase(end, msg.end());
124 TC_LOG_ERROR(
"network",
"HandleMessagechatOpcode : Unknown chat opcode ({})", chatMessage.
GetOpcode());
152 TC_LOG_ERROR(
"entities.player.cheat",
"CMSG_MESSAGECHAT: Possible hacking-attempt: {} tried to send a message in universal language",
GetPlayerInfo());
158 auto languageData =
sLanguageMgr->GetLanguageDescById(lang);
159 if (languageData.begin() == languageData.end())
165 if (std::none_of(languageData.begin(), languageData.end(),
166 [sender](std::pair<uint32 const, LanguageDesc>
const& langDesc) { return langDesc.second.SkillId == 0 || sender->HasSkill(langDesc.second.SkillId); }))
208 if (!ModLangAuras.empty())
209 lang =
Language(ModLangAuras.front()->GetMiscValue());
228 if (msg.size() > 511)
259 sender->
Say(msg, lang);
289 sender->
Yell(msg, lang);
446 sScriptMgr->OnPlayerChat(sender, type, lang, msg, chn);
468 TC_LOG_ERROR(
"network",
"CHAT: unknown message type {}, lang: {}", type, lang);
490 if (prefix.empty() || prefix.length() > 16)
512 if (text.length() > 255)
522 guild->BroadcastAddonToGuild(
this, type ==
CHAT_MSG_OFFICER, text, prefix, isLogged);
545 Group* group =
nullptr;
576 TC_LOG_ERROR(
"misc",
"HandleAddonMessagechatOpcode: unknown addon message type {}", type);
589 if (chatMessageAFK.
Text.length() > 511)
607 if (chatMessageAFK.
Text.empty())
623 guild->SendEventAwayChanged(sender->
GetGUID(), sender->
isAFK(), sender->
isDND());
635 if (chatMessageDND.
Text.length() > 511)
653 if (chatMessageDND.
Text.empty())
669 guild->SendEventAwayChanged(sender->
GetGUID(), sender->
isAFK(), sender->
isDND());
768 packet.
Reason = restriction;
790 canLocalWhisperTargetResponse.
Status = status;
bool ValidateMessage(Player const *player, std::string &msg)
DB2Storage< EmotesTextEntry > sEmotesTextStore("EmotesText.db2", &EmotesTextLoadInfo::Instance)
DB2Storage< ChatChannelsEntry > sChatChannelsStore("ChatChannels.db2", &ChatChannelsLoadInfo::Instance)
@ LANG_NOT_LEARNED_LANGUAGE
@ LANG_WAIT_BEFORE_SPEAKING
@ LANG_PLAYER_AFK_DEFAULT
@ LANG_PLAYER_DND_DEFAULT
#define TC_LOG_ERROR(filterType__,...)
ExtendedPlayerName ExtractExtendedPlayerName(std::string const &name)
bool normalizePlayerName(std::string &name)
std::optional< T > Optional
Optional helper class to wrap optional values within.
@ WhisperTargetWrongFaction
@ MessageHasInvalidCharacters
@ RaidWarningInPartyDisabled
@ CHAT_MSG_INSTANCE_CHAT_LEADER
@ SPELL_AURA_COMPREHEND_LANGUAGE
@ SPELL_AURA_MOD_LANGUAGE
std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
static std::string const PREFIX
static Channel * GetChannelForPlayerByNamePart(std::string const &namePart, Player *playerSearcher)
static Channel * GetChannelForPlayerByGuid(ObjectGuid channelGuid, Player *playerSearcher)
uint32 GetChannelId() const
void AddonSay(ObjectGuid const &guid, std::string const &prefix, std::string const &what, bool isLogged) const
void Say(ObjectGuid const &guid, std::string const &what, uint32 lang) const
uint8 GetMemberGroup(ObjectGuid guid) const
bool IsAssistant(ObjectGuid guid) const
bool IsLeader(ObjectGuid guid) const
void BroadcastAddonMessagePacket(WorldPacket const *packet, const std::string &prefix, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignore=ObjectGuid::Empty) const
void BroadcastPacket(WorldPacket const *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignoredPlayer=ObjectGuid::Empty) const
std::string ToString() const
static Creature * ToCreature(Object *o)
static ObjectGuid GetGUID(Object const *o)
void SendMessageToSetInRange(WorldPacket const *data, float dist, bool self) const override
bool IsGameMasterAcceptingWhispers() const
bool IsInWhisperWhiteList(ObjectGuid guid)
void SendDirectMessage(WorldPacket const *data) const
Group * GetOriginalGroup() const
WorldSession * GetSession() const
void WhisperAddon(std::string const &text, std::string const &prefix, bool isLogged, Player *receiver)
void UpdateCriteria(CriteriaType type, uint64 miscValue1=0, uint64 miscValue2=0, uint64 miscValue3=0, WorldObject *ref=nullptr)
ObjectGuid::LowType GetGuildId() const
bool IsGameMaster() const
void UpdateSpeakTime(ChatFloodThrottle::Index index)
void AddWhisperWhiteList(ObjectGuid guid)
Group * GetGroup(Optional< uint8 > partyIndex)
uint8 GetSubGroup() const
bool isAcceptWhispers() const
void Yell(std::string_view text, Language language, WorldObject const *=nullptr) override
Handles yelled message in regular chat based on declared language and in config pre-defined Range.
void Say(std::string_view text, Language language, WorldObject const *=nullptr) override
Handles said message in regular chat based on declared language and in config pre-defined Range.
void TextEmote(std::string_view text, WorldObject const *=nullptr, bool=false) override
Outputs an universal text which is supposed to be an action.
Team GetEffectiveTeam() const
void Whisper(std::string_view text, Language language, Player *receiver, bool=false) override
Handles whispers from Addons and players based on sender, receiver's guid and language.
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
bool HasAuraTypeWithMiscvalue(AuraType auraType, int32 miscValue) const
std::forward_list< AuraEffect * > AuraEffectList
void SetEmoteState(Emote emote)
void RemoveAurasWithInterruptFlags(InterruptFlags flag, SpellInfo const *source=nullptr)
bool HasUnitState(const uint32 f) const
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
void HandleEmoteCommand(Emote emoteId, Player *target=nullptr, Trinity::IteratorPair< int32 const * > spellVisualKitIds={}, int32 sequenceVariation=0)
std::string const & GetName() const
Array< int32, 2 > SpellVisualKitIDs
ChatWhisperTargetStatus Status
WorldPacket const * Write() override
ChatAddonMessageParams Params
Optional< ObjectGuid > ChannelGUID
ChatAddonMessageParams Params
WorldPacket const * Write() override
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string_view message, uint32 achievementId=0, std::string_view channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string_view addonPrefix="")
WorldPacket const * Write() override
WorldPacket const * Write() override
ObjectGuid SourceAccountGUID
WorldPacket const * Write() override
OpcodeClient GetOpcode() const
char const * GetTrinityString(uint32 entry) const
void HandleChatMessageEmoteOpcode(WorldPackets::Chat::ChatMessageEmote &chatMessageEmote)
void SendNotification(char const *format,...) ATTR_PRINTF(2
void HandleEmoteOpcode(WorldPackets::Chat::EmoteClient &packet)
void HandleChatMessageAFKOpcode(WorldPackets::Chat::ChatMessageAFK &chatMessageAFK)
ObjectGuid GetAccountGUID() const
std::string GetPlayerInfo() const
Player * GetPlayer() const
void HandleChatCanLocalWhisperTargetRequest(WorldPackets::Chat::CanLocalWhisperTargetRequest const &canLocalWhisperTargetRequest)
void HandleChatMessageChannelOpcode(WorldPackets::Chat::ChatMessageChannel &chatMessageChannel)
void SendChatRestricted(ChatRestrictionType restriction)
void SendChatPlayerNotfoundNotice(std::string const &name)
void HandleChatAddonMessage(ChatMsg type, std::string prefix, std::string text, bool isLogged, std::string target="", Optional< ObjectGuid > channelGuid={})
void SendPlayerAmbiguousNotice(std::string const &name)
ChatMessageResult HandleChatMessage(ChatMsg type, Language lang, std::string msg, std::string target="", Optional< ObjectGuid > channelGuid={})
bool HasPermission(uint32 permissionId)
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
void HandleTextEmoteOpcode(WorldPackets::Chat::CTextEmote &packet)
void HandleChatMessageWhisperOpcode(WorldPackets::Chat::ChatMessageWhisper &chatMessageWhisper)
void HandleChatMessageOpcode(WorldPackets::Chat::ChatMessage &chatMessage)
void HandleChatMessageDNDOpcode(WorldPackets::Chat::ChatMessageDND &chatMessageDND)
void HandleChatAddonMessageTargetedOpcode(WorldPackets::Chat::ChatAddonMessageTargeted &chatAddonMessageTargeted)
void HandleChatUpdateAADCStatus(WorldPackets::Chat::UpdateAADCStatus const &updateAADCStatus)
std::unique_ptr< Warden > _warden
bool ValidateHyperlinksAndMaybeKick(std::string const &str)
void HandleChatAddonMessageOpcode(WorldPackets::Chat::ChatAddonMessage &chatAddonMessage)
void HandleChatIgnoredOpcode(WorldPackets::Chat::ChatReportIgnored &chatReportIgnored)
@ CMSG_CHAT_MESSAGE_GUILD
@ CMSG_CHAT_MESSAGE_INSTANCE_CHAT
@ CMSG_CHAT_MESSAGE_RAID_WARNING
@ CMSG_CHAT_MESSAGE_OFFICER
@ CMSG_CHAT_MESSAGE_PARTY
@ CONFIG_CHAT_CHANNEL_LEVEL_REQ
@ CONFIG_CHAT_YELL_LEVEL_REQ
@ CONFIG_CHAT_WHISPER_LEVEL_REQ
@ CONFIG_CHAT_EMOTE_LEVEL_REQ
@ CONFIG_CHAT_SAY_LEVEL_REQ
@ CONFIG_CHAT_PARTY_RAID_WARNINGS
@ CONFIG_CHAT_FAKE_MESSAGE_PREVENTING
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD
@ CONFIG_LISTEN_RANGE_TEXTEMOTE
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
TC_GAME_API Player * FindPlayerByName(std::string_view name)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
TC_GAME_API Player * FindConnectedPlayerByName(std::string_view name)
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
@ RBAC_PERM_TWO_SIDE_INTERACTION_CHAT
@ RBAC_PERM_CAN_FILTER_WHISPERS
@ RBAC_PERM_SKIP_CHECK_CHAT_CHANNEL_REQ