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
 

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 *, 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)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ message_commandscript()

message_commandscript::message_commandscript ( )
inline
42: CommandScript("message_commandscript") { }
Definition: ScriptMgr.h:850

Member Function Documentation

◆ GetCommands()

ChatCommandTable message_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

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

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

◆ HandleAnnounceCommand()

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

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

Referenced by GetCommands().

◆ HandleGMAnnounceCommand()

static bool message_commandscript::HandleGMAnnounceCommand ( ChatHandler ,
Tail  message 
)
inlinestatic
97 {
98 if (message.empty())
99 return false;
100
101 sWorld->SendGMText(LANG_GM_BROADCAST, message.data());
102 return true;
103 }
@ LANG_GM_BROADCAST
Definition: Language.h:1167

References LANG_GM_BROADCAST, and sWorld.

Referenced by GetCommands().

◆ HandleGMNameAnnounceCommand()

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

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

Referenced by GetCommands().

◆ HandleGMNotifyCommand()

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

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

Referenced by GetCommands().

◆ HandleNameAnnounceCommand()

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

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

Referenced by GetCommands().

◆ HandleNotifyCommand()

static bool message_commandscript::HandleNotifyCommand ( ChatHandler handler,
Tail  message 
)
inlinestatic
107 {
108 if (message.empty())
109 return false;
110
111 std::string str = handler->GetAcoreString(LANG_GLOBAL_NOTIFY);
112 str += message;
113
114 WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1));
115 data << str;
116 sWorld->SendGlobalMessage(&data);
117
118 return true;
119 }
@ 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
139 {
140 if (!operationArg)
141 {
143 return true;
144 }
145
146 if (operationArg->holds_alternative<bool>())
147 {
148 if (operationArg->get<bool>())
149 {
150 handler->GetSession()->GetPlayer()->SetAcceptWhispers(true);
152 return true;
153 }
154 else
155 {
156 // Remove all players from the Gamemaster's whisper whitelist
158 handler->GetSession()->GetPlayer()->SetAcceptWhispers(false);
160 return true;
161 }
162 }
163
164 if (operationArg->holds_alternative<EXACT_SEQUENCE("remove")>())
165 {
166 if (!playerNameArg)
167 return false;
168
169 if (normalizePlayerName(*playerNameArg))
170 {
171 if (Player* player = ObjectAccessor::FindPlayerByName(*playerNameArg))
172 {
173 handler->GetSession()->GetPlayer()->RemoveFromWhisperWhiteList(player->GetGUID());
174 handler->PSendSysMessage(LANG_COMMAND_WHISPEROFFPLAYER, playerNameArg->c_str());
175 return true;
176 }
177 else
178 {
179 handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND, playerNameArg->c_str());
180 handler->SetSentErrorMessage(true);
181 return false;
182 }
183 }
184 }
186 handler->SetSentErrorMessage(true);
187 return false;
188 }
#define EXACT_SEQUENCE(str)
Definition: ChatCommandTags.h:114
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:264
@ 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:522
@ LANG_COMMAND_WHISPEROFFPLAYER
Definition: Language.h:404
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:276
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
Definition: Player.h:1046
void SetAcceptWhispers(bool on)
Definition: Player.h:1135
void ClearWhisperWhiteList()
Definition: Player.h:2505
void RemoveFromWhisperWhiteList(ObjectGuid guid)
Definition: Player.h:2508
bool isAcceptWhispers() const
Definition: Player.h:1134
Player * GetPlayer() const
Definition: WorldSession.h:361

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::SendSysMessage(), Player::SetAcceptWhispers(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().