AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
message_commandscript Class Reference
Inheritance diagram for message_commandscript:
CommandScript ScriptObject

Public Member Functions

 message_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleNameAnnounceCommand (ChatHandler *handler, Tail message)
 
static bool HandleGMNameAnnounceCommand (ChatHandler *handler, Tail message)
 
static bool HandleAnnounceCommand (ChatHandler *handler, Tail message)
 
static bool HandleGMAnnounceCommand (ChatHandler *handler, Tail message)
 
static bool HandleNotifyCommand (ChatHandler *handler, Tail message)
 
static bool HandleGMNotifyCommand (ChatHandler *handler, Tail message)
 
static bool HandleWhispersCommand (ChatHandler *handler, Optional< Variant< bool, EXACT_SEQUENCE("remove")> > operationArg, Optional< std::string > playerNameArg)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ message_commandscript()

message_commandscript::message_commandscript ( )
inline
41: CommandScript("message_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable message_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

44 {
45 static ChatCommandTable commandTable =
46 {
47 { "nameannounce", HandleNameAnnounceCommand, SEC_GAMEMASTER, Console::Yes },
48 { "gmnameannounce", HandleGMNameAnnounceCommand, SEC_GAMEMASTER, Console::Yes },
49 { "announce", HandleAnnounceCommand, SEC_GAMEMASTER, Console::Yes },
50 { "gmannounce", HandleGMAnnounceCommand, SEC_GAMEMASTER, Console::Yes },
51 { "notify", HandleNotifyCommand, SEC_GAMEMASTER, Console::Yes },
52 { "gmnotify", HandleGMNotifyCommand, SEC_GAMEMASTER, Console::Yes },
53 { "whispers", HandleWhispersCommand, SEC_MODERATOR, Console::No },
54 };
55 return commandTable;
56 }
@ SEC_GAMEMASTER
Definition: Common.h:59
@ SEC_MODERATOR
Definition: Common.h:58
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleNotifyCommand(ChatHandler *handler, Tail message)
Definition: cs_message.cpp:105
static bool HandleGMNotifyCommand(ChatHandler *handler, Tail message)
Definition: cs_message.cpp:121
static bool HandleNameAnnounceCommand(ChatHandler *handler, Tail message)
Definition: cs_message.cpp:58
static bool HandleAnnounceCommand(ChatHandler *handler, Tail message)
Definition: cs_message.cpp:85
static bool HandleWhispersCommand(ChatHandler *handler, Optional< Variant< bool, EXACT_SEQUENCE("remove")> > operationArg, Optional< std::string > playerNameArg)
Definition: cs_message.cpp:137
static bool HandleGMNameAnnounceCommand(ChatHandler *handler, Tail message)
Definition: cs_message.cpp:71
static bool HandleGMAnnounceCommand(ChatHandler *handler, Tail message)
Definition: cs_message.cpp:95

References HandleAnnounceCommand(), HandleGMAnnounceCommand(), HandleGMNameAnnounceCommand(), HandleGMNotifyCommand(), HandleNameAnnounceCommand(), HandleNotifyCommand(), HandleWhispersCommand(), SEC_GAMEMASTER, and SEC_MODERATOR.

◆ HandleAnnounceCommand()

static bool message_commandscript::HandleAnnounceCommand ( ChatHandler handler,
Tail  message 
)
inlinestatic
86 {
87 if (message.empty())
88 return false;
89
90 sWorld->SendServerMessage(SERVER_MSG_STRING, Acore::StringFormat(handler->GetAcoreString(LANG_SYSTEMMESSAGE), message.data()));
91 return true;
92 }
@ LANG_SYSTEMMESSAGE
Definition: Language.h:35
@ SERVER_MSG_STRING
Definition: IWorld.h:58
#define sWorld
Definition: World.h:443
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default AC string format function.
Definition: StringFormat.h:34
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:40

References ChatHandler::GetAcoreString(), LANG_SYSTEMMESSAGE, SERVER_MSG_STRING, Acore::StringFormat(), and sWorld.

Referenced by GetCommands().

◆ HandleGMAnnounceCommand()

static bool message_commandscript::HandleGMAnnounceCommand ( ChatHandler handler,
Tail  message 
)
inlinestatic
96 {
97 if (message.empty())
98 return false;
99
100 handler->SendGMText(LANG_GM_BROADCAST, message.data());
101 return true;
102 }
@ LANG_GM_BROADCAST
Definition: Language.h:1162
void SendGMText(std::string_view str)
Definition: Chat.cpp:115

References LANG_GM_BROADCAST, and ChatHandler::SendGMText().

Referenced by GetCommands().

◆ HandleGMNameAnnounceCommand()

static bool message_commandscript::HandleGMNameAnnounceCommand ( ChatHandler handler,
Tail  message 
)
inlinestatic
72 {
73 if (message.empty())
74 return false;
75
76 std::string name("Console");
77 if (WorldSession* session = handler->GetSession())
78 name = session->GetPlayer()->GetName();
79
80 handler->SendGMText(LANG_GM_ANNOUNCE_COLOR, name, message.data());
81 return true;
82 }
@ LANG_GM_ANNOUNCE_COLOR
Definition: Language.h:1164
WorldSession * GetSession()
Definition: Chat.h:242
Player session in the World.
Definition: WorldSession.h:330

References ChatHandler::GetSession(), LANG_GM_ANNOUNCE_COLOR, and ChatHandler::SendGMText().

Referenced by GetCommands().

◆ HandleGMNotifyCommand()

static bool message_commandscript::HandleGMNotifyCommand ( ChatHandler handler,
Tail  message 
)
inlinestatic
122 {
123 if (message.empty())
124 return false;
125
126 std::string str = handler->GetAcoreString(LANG_GM_NOTIFY);
127 str += message;
128
129 WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1));
130 data << str;
131 sWorld->SendGlobalGMMessage(&data);
132
133 return true;
134 }
@ LANG_GM_NOTIFY
Definition: Language.h:1163
@ SMSG_NOTIFICATION
Definition: Opcodes.h:489
Definition: WorldPacket.h:26

References ChatHandler::GetAcoreString(), LANG_GM_NOTIFY, SMSG_NOTIFICATION, and sWorld.

Referenced by GetCommands().

◆ HandleNameAnnounceCommand()

static bool message_commandscript::HandleNameAnnounceCommand ( ChatHandler handler,
Tail  message 
)
inlinestatic
59 {
60 if (message.empty())
61 return false;
62
63 std::string name("Console");
64 if (WorldSession* session = handler->GetSession())
65 name = session->GetPlayer()->GetName();
66
67 handler->SendWorldText(LANG_ANNOUNCE_COLOR, name, message.data());
68 return true;
69 }
@ LANG_ANNOUNCE_COLOR
Definition: Language.h:734
void SendWorldText(std::string_view str)
Definition: Chat.cpp:130

References ChatHandler::GetSession(), LANG_ANNOUNCE_COLOR, and ChatHandler::SendWorldText().

Referenced by GetCommands().

◆ HandleNotifyCommand()

static bool message_commandscript::HandleNotifyCommand ( ChatHandler handler,
Tail  message 
)
inlinestatic
106 {
107 if (message.empty())
108 return false;
109
110 std::string str = handler->GetAcoreString(LANG_GLOBAL_NOTIFY);
111 str += message;
112
113 WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1));
114 data << str;
115 sWorld->SendGlobalMessage(&data);
116
117 return true;
118 }
@ LANG_GLOBAL_NOTIFY
Definition: Language.h:132

References ChatHandler::GetAcoreString(), LANG_GLOBAL_NOTIFY, SMSG_NOTIFICATION, and sWorld.

Referenced by GetCommands().

◆ HandleWhispersCommand()

static bool message_commandscript::HandleWhispersCommand ( ChatHandler handler,
Optional< Variant< bool, EXACT_SEQUENCE("remove")> >  operationArg,
Optional< std::string >  playerNameArg 
)
inlinestatic
138 {
139 if (!operationArg)
140 {
142 return true;
143 }
144
145 if (operationArg->holds_alternative<bool>())
146 {
147 if (operationArg->get<bool>())
148 {
149 handler->GetSession()->GetPlayer()->SetAcceptWhispers(true);
151 return true;
152 }
153 else
154 {
155 // Remove all players from the Gamemaster's whisper whitelist
157 handler->GetSession()->GetPlayer()->SetAcceptWhispers(false);
159 return true;
160 }
161 }
162
163 if (operationArg->holds_alternative<EXACT_SEQUENCE("remove")>())
164 {
165 if (!playerNameArg)
166 return false;
167
168 if (normalizePlayerName(*playerNameArg))
169 {
170 if (Player* player = ObjectAccessor::FindPlayerByName(*playerNameArg))
171 {
172 handler->GetSession()->GetPlayer()->RemoveFromWhisperWhiteList(player->GetGUID());
173 handler->PSendSysMessage(LANG_COMMAND_WHISPEROFFPLAYER, playerNameArg->c_str());
174 return true;
175 }
176 else
177 {
178 handler->SendErrorMessage(LANG_PLAYER_NOT_FOUND, playerNameArg->c_str());
179 return false;
180 }
181 }
182 }
184 return false;
185 }
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:208
@ LANG_COMMAND_WHISPEROFF
Definition: Language.h:331
@ LANG_USE_BOL
Definition: Language.h:303
@ LANG_OFF
Definition: Language.h:71
@ LANG_COMMAND_WHISPERACCEPTING
Definition: Language.h:329
@ LANG_ON
Definition: Language.h:70
@ LANG_COMMAND_WHISPERON
Definition: Language.h:330
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:539
@ LANG_COMMAND_WHISPEROFFPLAYER
Definition: Language.h:404
#define EXACT_SEQUENCE(str)
Definition: ChatCommandTags.h:109
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:271
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
Definition: Player.h:1064
void SetAcceptWhispers(bool on)
Definition: Player.h:1157
void ClearWhisperWhiteList()
Definition: Player.h:2541
void RemoveFromWhisperWhiteList(ObjectGuid guid)
Definition: Player.h:2544
bool isAcceptWhispers() const
Definition: Player.h:1156
Player * GetPlayer() const
Definition: WorldSession.h:362

References Player::ClearWhisperWhiteList(), EXACT_SEQUENCE, ObjectAccessor::FindPlayerByName(), ChatHandler::GetAcoreString(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Player::isAcceptWhispers(), LANG_COMMAND_WHISPERACCEPTING, LANG_COMMAND_WHISPEROFF, LANG_COMMAND_WHISPEROFFPLAYER, LANG_COMMAND_WHISPERON, LANG_OFF, LANG_ON, LANG_PLAYER_NOT_FOUND, LANG_USE_BOL, normalizePlayerName(), ChatHandler::PSendSysMessage(), Player::RemoveFromWhisperWhiteList(), ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), and Player::SetAcceptWhispers().

Referenced by GetCommands().