TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
message_commandscript Class Reference

Public Member Functions

 message_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleChannelSetOwnership (ChatHandler *handler, char const *args)
 
static bool HandleNameAnnounceCommand (ChatHandler *handler, char const *args)
 
static bool HandleGMNameAnnounceCommand (ChatHandler *handler, char const *args)
 
static bool HandleAnnounceCommand (ChatHandler *handler, char const *args)
 
static bool HandleGMAnnounceCommand (ChatHandler *, char const *args)
 
static bool HandleNotifyCommand (ChatHandler *handler, char const *args)
 
static bool HandleGMNotifyCommand (ChatHandler *handler, char const *args)
 
static bool HandleWhispersCommand (ChatHandler *handler, char const *args)
 

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 ()
 

Constructor & Destructor Documentation

message_commandscript::message_commandscript ( )
inline
35 : CommandScript("message_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> message_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

38  {
39  static std::vector<ChatCommand> channelSetCommandTable =
40  {
42  };
43  static std::vector<ChatCommand> channelCommandTable =
44  {
45  { "set", rbac::RBAC_PERM_COMMAND_CHANNEL_SET, true, NULL, "", channelSetCommandTable },
46  };
47  static std::vector<ChatCommand> commandTable =
48  {
49  { "channel", rbac::RBAC_PERM_COMMAND_CHANNEL, true, NULL, "", channelCommandTable },
52  { "announce", rbac::RBAC_PERM_COMMAND_ANNOUNCE, true, &HandleAnnounceCommand, "" },
53  { "gmannounce", rbac::RBAC_PERM_COMMAND_GMANNOUNCE, true, &HandleGMAnnounceCommand, "" },
54  { "notify", rbac::RBAC_PERM_COMMAND_NOTIFY, true, &HandleNotifyCommand, "" },
55  { "gmnotify", rbac::RBAC_PERM_COMMAND_GMNOTIFY, true, &HandleGMNotifyCommand, "" },
56  { "whispers", rbac::RBAC_PERM_COMMAND_WHISPERS, false, &HandleWhispersCommand, "" },
57  };
58  return commandTable;
59  }
static bool HandleNotifyCommand(ChatHandler *handler, char const *args)
Definition: cs_message.cpp:149
static bool HandleGMAnnounceCommand(ChatHandler *, char const *args)
Definition: cs_message.cpp:140
static bool HandleChannelSetOwnership(ChatHandler *handler, char const *args)
Definition: cs_message.cpp:61
static bool HandleGMNameAnnounceCommand(ChatHandler *handler, char const *args)
Definition: cs_message.cpp:116
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: RBAC.h:370
static bool HandleGMNotifyCommand(ChatHandler *handler, char const *args)
Definition: cs_message.cpp:162
Definition: RBAC.h:378
static bool HandleAnnounceCommand(ChatHandler *handler, char const *args)
Definition: cs_message.cpp:129
static bool HandleWhispersCommand(ChatHandler *handler, char const *args)
Definition: cs_message.cpp:175
static bool HandleNameAnnounceCommand(ChatHandler *handler, char const *args)
Definition: cs_message.cpp:103
Definition: RBAC.h:375
Definition: RBAC.h:377
Definition: RBAC.h:369

+ Here is the call graph for this function:

static bool message_commandscript::HandleAnnounceCommand ( ChatHandler handler,
char const args 
)
inlinestatic
130  {
131  if (!*args)
132  return false;
133 
134  std::string str = handler->PGetParseString(LANG_SYSTEMMESSAGE, args);
135 
136  sWorld->SendServerMessage(SERVER_MSG_STRING, str);
137  return true;
138  }
Definition: Language.h:36
std::string PGetParseString(uint32 entry, Args &&...args) const
Definition: Chat.h:84
#define sWorld
Definition: World.h:887
Definition: World.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool message_commandscript::HandleChannelSetOwnership ( ChatHandler handler,
char const args 
)
inlinestatic
62  {
63  if (!*args)
64  return false;
65  char const* channelStr = strtok((char*)args, " ");
66  char const* argStr = strtok(NULL, "");
67 
68  if (!channelStr || !argStr)
69  return false;
70 
71  Player* player = handler->GetSession()->GetPlayer();
72  Channel* channcel = NULL;
73 
74  if (ChannelMgr* cMgr = ChannelMgr::ForTeam(player->GetTeam()))
75  channcel = cMgr->GetChannel(channelStr, player);
76 
77  if (strcmp(argStr, "on") == 0)
78  {
79  if (channcel)
80  channcel->SetOwnership(true);
82  stmt->setUInt8 (0, 1);
83  stmt->setString(1, channelStr);
85  handler->PSendSysMessage(LANG_CHANNEL_ENABLE_OWNERSHIP, channelStr);
86  }
87  else if (strcmp(argStr, "off") == 0)
88  {
89  if (channcel)
90  channcel->SetOwnership(false);
92  stmt->setUInt8 (0, 0);
93  stmt->setString(1, channelStr);
95  handler->PSendSysMessage(LANG_CHANNEL_DISABLE_OWNERSHIP, channelStr);
96  }
97  else
98  return false;
99 
100  return true;
101  }
static ChannelMgr * ForTeam(uint32 team)
Definition: ChannelMgr.cpp:30
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:213
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: Language.h:1089
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Channel.h:126
Definition: PreparedStatement.h:74
void SetOwnership(bool ownership)
Definition: Channel.h:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: ChannelMgr.h:27
WorldSession * GetSession()
Definition: Chat.h:59
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: Language.h:1088

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool message_commandscript::HandleGMAnnounceCommand ( ChatHandler ,
char const args 
)
inlinestatic
141  {
142  if (!*args)
143  return false;
144 
145  sWorld->SendGMText(LANG_GM_BROADCAST, args);
146  return true;
147  }
#define sWorld
Definition: World.h:887
Definition: Language.h:1147

+ Here is the caller graph for this function:

static bool message_commandscript::HandleGMNameAnnounceCommand ( ChatHandler handler,
char const args 
)
inlinestatic
117  {
118  if (!*args)
119  return false;
120 
121  std::string name("Console");
122  if (WorldSession* session = handler->GetSession())
123  name = session->GetPlayer()->GetName();
124 
125  sWorld->SendGMText(LANG_GM_ANNOUNCE_COLOR, name.c_str(), args);
126  return true;
127  }
Definition: Language.h:1149
#define sWorld
Definition: World.h:887
WorldSession * GetSession()
Definition: Chat.h:59
Player session in the World.
Definition: WorldSession.h:882

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool message_commandscript::HandleGMNotifyCommand ( ChatHandler handler,
char const args 
)
inlinestatic
163  {
164  if (!*args)
165  return false;
166 
167  std::string str = handler->GetTrinityString(LANG_GM_NOTIFY);
168  str += args;
169 
170  sWorld->SendGlobalGMMessage(WorldPackets::Chat::PrintNotification(str).Write());
171 
172  return true;
173  }
#define sWorld
Definition: World.h:887
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
Definition: Language.h:1148
Definition: ChatPackets.h:220

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool message_commandscript::HandleNameAnnounceCommand ( ChatHandler handler,
char const args 
)
inlinestatic
104  {
105  if (!*args)
106  return false;
107 
108  std::string name("Console");
109  if (WorldSession* session = handler->GetSession())
110  name = session->GetPlayer()->GetName();
111 
112  sWorld->SendWorldText(LANG_ANNOUNCE_COLOR, name.c_str(), args);
113  return true;
114  }
#define sWorld
Definition: World.h:887
WorldSession * GetSession()
Definition: Chat.h:59
Player session in the World.
Definition: WorldSession.h:882
Definition: Language.h:764

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool message_commandscript::HandleNotifyCommand ( ChatHandler handler,
char const args 
)
inlinestatic
150  {
151  if (!*args)
152  return false;
153 
154  std::string str = handler->GetTrinityString(LANG_GLOBAL_NOTIFY);
155  str += args;
156 
157  sWorld->SendGlobalMessage(WorldPackets::Chat::PrintNotification(str).Write());
158 
159  return true;
160  }
#define sWorld
Definition: World.h:887
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
Definition: Language.h:124
Definition: ChatPackets.h:220

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool message_commandscript::HandleWhispersCommand ( ChatHandler handler,
char const args 
)
inlinestatic
176  {
177  if (!*args)
178  {
179  handler->PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, handler->GetSession()->GetPlayer()->isAcceptWhispers() ? handler->GetTrinityString(LANG_ON) : handler->GetTrinityString(LANG_OFF));
180  return true;
181  }
182 
183  std::string argStr = strtok((char*)args, " ");
184  // whisper on
185  if (argStr == "on")
186  {
187  handler->GetSession()->GetPlayer()->SetAcceptWhispers(true);
189  return true;
190  }
191 
192  // whisper off
193  if (argStr == "off")
194  {
195  // Remove all players from the Gamemaster's whisper whitelist
196  handler->GetSession()->GetPlayer()->ClearWhisperWhiteList();
197  handler->GetSession()->GetPlayer()->SetAcceptWhispers(false);
199  return true;
200  }
201 
202  if (argStr == "remove")
203  {
204  std::string name = strtok(NULL, " ");
205  if (normalizePlayerName(name))
206  {
207  if (Player* player = ObjectAccessor::FindPlayerByName(name))
208  {
209  handler->GetSession()->GetPlayer()->RemoveFromWhisperWhiteList(player->GetGUID());
210  handler->PSendSysMessage(LANG_COMMAND_WHISPEROFFPLAYER, name.c_str());
211  return true;
212  }
213  else
214  {
215  handler->PSendSysMessage(LANG_PLAYER_NOT_FOUND, name.c_str());
216  handler->SetSentErrorMessage(true);
217  return false;
218  }
219  }
220  }
221  handler->SendSysMessage(LANG_USE_BOL);
222  handler->SetSentErrorMessage(true);
223  return false;
224  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:316
Definition: Language.h:317
Player * GetPlayer() const
Definition: WorldSession.h:927
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
Definition: Language.h:290
Definition: Language.h:318
Definition: Language.h:72
TC_GAME_API Player * FindPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:220
Definition: Language.h:391
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: Language.h:509
Definition: Language.h:71

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: