42 return strprintf(
_(
"Options to /%s are \"yes\", \"no\", \"true\", \"false\", \"1\", \"0\"."),
51 std::string::size_type pos = command.find(
' ');
52 std::string type(command, 0, pos);
53 std::string args(command, pos == std::string::npos ?
54 command.size() : pos + 1);
65 else if (type ==
"where")
69 else if (type ==
"who")
73 else if (type ==
"msg" || type ==
"whisper" || type ==
"w")
77 else if (type ==
"query" || type ==
"q")
81 else if (type ==
"ignore")
85 else if (type ==
"unignore")
89 else if (type ==
"join")
93 else if (type ==
"list")
97 else if (type ==
"clear")
101 else if (type ==
"createparty")
105 else if (type ==
"party")
109 else if (type ==
"me")
113 else if (type ==
"record")
117 else if (type ==
"toggle")
121 else if (type ==
"present")
129 else if (type ==
"away")
135 tab->
chatLog(
_(
"Unknown command."));
141 std::string opt = value.substr(0, 1);
144 opt ==
"y" || opt ==
"Y" ||
145 opt ==
"t" || opt ==
"T")
147 else if (opt ==
"0" ||
148 opt ==
"n" || opt ==
"N" ||
149 opt ==
"f" || opt ==
"F")
160 tab->
chatLog(
_(
"/help > Display this help"));
162 tab->
chatLog(
_(
"/where > Display map name"));
165 tab->
chatLog(
_(
"/who > Display number of online users"));
167 tab->
chatLog(
_(
"/me > Tell something about yourself"));
169 tab->
chatLog(
_(
"/clear > Clears this window"));
171 tab->
chatLog(
_(
"/msg > Send a private message to a user"));
172 tab->
chatLog(
_(
"/whisper > Alias of msg"));
173 tab->
chatLog(
_(
"/w > Alias of msg"));
174 tab->
chatLog(
_(
"/query > Makes a tab for private messages "
175 "with another user"));
176 tab->
chatLog(
_(
"/q > Alias of query"));
178 tab->
chatLog(
_(
"/away > Tell the other whispering players "
179 "you're away from keyboard."));
181 tab->
chatLog(
_(
"/ignore > ignore a player"));
182 tab->
chatLog(
_(
"/unignore > stop ignoring a player"));
184 tab->
chatLog(
_(
"/list > Display all public channels"));
185 tab->
chatLog(
_(
"/join > Join or create a channel"));
187 tab->
chatLog(
_(
"/createparty > Create a new party"));
188 tab->
chatLog(
_(
"/party > Invite a user to party"));
190 tab->
chatLog(
_(
"/record > Start recording the chat "
191 "to an external file"));
192 tab->
chatLog(
_(
"/toggle > Determine whether <return> "
193 "toggles the chat log"));
194 tab->
chatLog(
_(
"/present > Get list of players present "
195 "(sent to chat log, if logging)"));
199 tab->
chatLog(
_(
"For more information, type /help <command>."));
201 else if (args ==
"help")
204 tab->
chatLog(
_(
"This command displays a list "
205 "of all commands available."));
206 tab->
chatLog(
_(
"Command: /help <command>"));
207 tab->
chatLog(
_(
"This command displays help on <command>."));
213 else if (args ==
"clear")
216 tab->
chatLog(
_(
"This command clears the chat log of previous chat."));
218 else if (args ==
"ignore")
220 tab->
chatLog(
_(
"Command: /ignore <player>"));
221 tab->
chatLog(
_(
"This command ignores the given player regardless of "
222 "current relations."));
224 else if (args ==
"join")
226 tab->
chatLog(
_(
"Command: /join <channel>"));
227 tab->
chatLog(
_(
"This command makes you enter <channel>."));
228 tab->
chatLog(
_(
"If <channel> doesn't exist, it's created."));
230 else if (args ==
"list")
233 tab->
chatLog(
_(
"This command shows a list of all channels."));
235 else if (args ==
"me")
237 tab->
chatLog(
_(
"Command: /me <message>"));
238 tab->
chatLog(
_(
"This command tell others you are (doing) <msg>."));
240 else if (args ==
"msg" || args ==
"whisper" || args ==
"w")
242 tab->
chatLog(
_(
"Command: /msg <nick> <message>"));
243 tab->
chatLog(
_(
"Command: /whisper <nick> <message>"));
244 tab->
chatLog(
_(
"Command: /w <nick> <message>"));
245 tab->
chatLog(
_(
"This command sends the text <message> to <nick>."));
246 tab->
chatLog(
_(
"If the <nick> has spaces in it, enclose it in "
247 "double quotes (\")."));
249 else if (args ==
"query" || args ==
"q")
251 tab->
chatLog(
_(
"Command: /query <nick>"));
252 tab->
chatLog(
_(
"Command: /q <nick>"));
253 tab->
chatLog(
_(
"This command tries to make a tab for whispers between "
256 else if (args ==
"away")
258 tab->
chatLog(
_(
"Command: /away <afk reason>"));
259 tab->
chatLog(
_(
"This command tells "
260 "you're away from keyboard with the given reason."));
262 tab->
chatLog(
_(
"This command clears the away status and message."));
264 else if (args ==
"createparty")
266 tab->
chatLog(
_(
"Command: /createparty <name>"));
267 tab->
chatLog(
_(
"This command creates a new party called <name>."));
269 else if (args ==
"party")
271 tab->
chatLog(
_(
"Command: /party <nick>"));
272 tab->
chatLog(
_(
"This command invites <nick> to party with you."));
273 tab->
chatLog(
_(
"If the <nick> has spaces in it, enclose it in "
274 "double quotes (\")."));
276 else if (args ==
"present")
278 tab->
chatLog(
_(
"Command: /present"));
279 tab->
chatLog(
_(
"This command gets a list of players within hearing and "
280 "sends it to either the record log if recording, or the chat "
283 else if (args ==
"record")
285 tab->
chatLog(
_(
"Command: /record <filename>"));
286 tab->
chatLog(
_(
"This command starts recording the chat log to the file "
288 tab->
chatLog(
_(
"Command: /record"));
289 tab->
chatLog(
_(
"This command finishes a recording session."));
291 else if (args ==
"toggle")
293 tab->
chatLog(
_(
"Command: /toggle <state>"));
294 tab->
chatLog(
_(
"This command sets whether the return key should toggle the "
295 "chat log, or whether the chat log turns off automatically."));
296 tab->
chatLog(
_(
"<state> can be one of \"1\", \"yes\", \"true\" to "
297 "turn the toggle on, or \"0\", \"no\", \"false\" to turn the "
299 tab->
chatLog(
_(
"Command: /toggle"));
300 tab->
chatLog(
_(
"This command displays the return toggle status."));
302 else if (args ==
"unignore")
304 tab->
chatLog(
_(
"Command: /unignore <player>"));
305 tab->
chatLog(
_(
"This command stops ignoring the given player if they "
306 "are being ignored"));
308 else if (args ==
"where")
311 tab->
chatLog(
_(
"This command displays the name of the current map."));
316 tab->
chatLog(
_(
"This command displays the number of players currently "
321 tab->
chatLog(
_(
"Unknown command."));
322 tab->
chatLog(
_(
"Type /help for a list of commands."));
328 std::ostringstream where;
343 std::string recvnick;
346 if (args.substr(0, 1) ==
"\"")
348 const std::string::size_type pos = args.find(
'"', 1);
349 if (pos != std::string::npos)
351 recvnick = args.substr(1, pos - 1);
352 if (pos + 2 < args.length())
353 msg = args.substr(pos + 2, args.length());
358 const std::string::size_type pos = args.find(
" ");
359 if (pos != std::string::npos)
361 recvnick = args.substr(0, pos);
362 if (pos + 1 < args.length())
363 msg = args.substr(pos + 1, args.length());
367 recvnick = std::string(args);
374 if (msg.length() > 0)
377 std::string tempNick = recvnick;
382 if (tempNick.compare(playerName) == 0 || args.empty())
399 if (args.length() > 1 && args[0] ==
'\"' && args[args.length() - 1] ==
'\"')
410 "It either already exists, or is you."), args.c_str()),
BY_SERVER);
420 std::string::size_type pos = args.find(
' ');
421 std::string name(args, 0, pos);
422 std::string password(args, pos + 1);
463 :
_(
"Message closes chat."));
472 tab->
chatLog(
_(
"Return now toggles chat."));
476 tab->
chatLog(
_(
"Message now closes chat."));
489 _(
"Show IP: On") :
_(
"Show IP: Off"));
ActorSpriteManager * actorSpriteManager
int getTileX() const override
Returns the tile x coord.
const std::string & getName() const
Returns the name of the being.
int getTileY() const override
Returns the tile y coord.
A tab for the chat window.
void chatLog(std::string line, Own own=BY_SERVER, bool ignoreRecord=false)
Adds a line of text to our message list.
virtual bool handleCommand(const std::string &type, const std::string &args)
Handle special commands.
virtual void showHelp()
Add any extra help text to the output.
void whisper(const std::string &nick, const std::string &mes, Own own=BY_OTHER)
void clearTab()
Clear the current tab.
void setRecordingFile(const std::string &msg)
Sets the file being recorded to.
ChatTab * addWhisperTab(const std::string &nick, bool switchTo=false)
void handlePresent(const std::string &args, ChatTab *tab)
Handle a present command.
void handleCommand(const std::string &command, ChatTab *tab=localChatTab)
Parse and handle the given command.
void handleQuery(const std::string &args, ChatTab *tab)
Handle a msg tab request.
void handleIgnore(const std::string &args, ChatTab *tab)
Handle an ignore command.
void handleShowIp(const std::string &args, ChatTab *tab)
void handleClear(const std::string &args, ChatTab *tab)
Handle a clear command.
static char parseBoolean(const std::string &value)
void handleParty(const std::string &args, ChatTab *tab)
Handle a party command.
void handleMe(const std::string &args, ChatTab *tab)
Handle a me command.
void handleListChannels(const std::string &args, ChatTab *tab)
Handle a listchannels command.
void handleWhere(const std::string &args, ChatTab *tab)
Handle a where command.
void handleRecord(const std::string &args, ChatTab *tab)
Handle a record command.
void handleWho(const std::string &args, ChatTab *tab)
Handle a who command.
void handleHelp(const std::string &args, ChatTab *tab)
Handle a help command.
void handleCreateParty(const std::string &args, ChatTab *tab)
Handle a createparty command.
void handleJoin(const std::string &args, ChatTab *tab)
Handle a join command.
void handleAway(const std::string &args, ChatTab *tab)
Handle away command.
void handleUnignore(const std::string &args, ChatTab *tab)
Handle an unignore command.
void handleToggle(const std::string &args, ChatTab *tab)
Handle a toggle command.
void handleMsg(const std::string &args, ChatTab *tab)
Handle a msg command.
const std::string & getCurrentMapName()
static Game * instance()
Provides access to the game instance.
void setShowIp(bool show)
void setAwayMode(bool away)
virtual void enterChannel(const std::string &channel, const std::string &password)=0
virtual void me(const std::string &text)=0
virtual void channelList()=0
virtual void create(const std::string &name=std::string())=0
virtual void invite(Being *player)=0
PlayerRelation getRelation(const std::string &name) const
Updates the relationship with this player.
void setRelation(const std::string &name, PlayerRelation relation)
Updates the relationship with this player.
void removePlayer(const std::string &name)
Deletes the information recorded for a player.
Config config
Global settings (config.xml)
std::string booleanOptionInstructions(const char *command)
std::string booleanOptionInstructions(const char *command)
LocalPlayer * local_player
ServerType getNetworkType()
ChatHandler * getChatHandler()
PartyHandler * getPartyHandler()
PlayerRelationsManager player_relations
std::string & toLower(std::string &str)
Converts the given string to lower case.
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
std::string & trim(std::string &str)
Trims spaces off the end and the beginning of the given string.