The Battle for Wesnoth  1.15.1+dev
chat_command_handler.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017-2018 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
16 #include "map_command_handler.hpp"
17 #include "gettext.hpp"
18 
19 namespace events {
20  class chat_handler;
21 //command handler for chat /commands
22 class chat_command_handler : public map_command_handler<chat_command_handler>
23 {
24 public:
26  chat_command_handler(chat_handler& chathandler, bool allies_only)
27  : map(), chat_handler_(chathandler), allies_only_(allies_only)
28  {
29  }
30 
31 protected:
32  void do_emote();
33  void do_network_send();
35  void do_room_query();
36  void do_room_query_noarg();
37  void do_gen_room_query();
38  void do_whisper();
39  void do_chanmsg();
40  void do_log();
41  void do_ignore();
42  void do_friend();
43  void do_remove();
44  void do_display();
45  void do_version();
46 
47  /** Request information about a user from the server. */
48  void do_info();
49 
50  std::string get_flags_description() const {
51  return _("(A) — admin command");
52  }
53 
56  {
57  if (c.has_flag('A')) {
58  return std::string(" ") + _("(admin only)");
59  }
60  else {
61  return "";
62  }
63  }
64 
66 
67  void print(const std::string& title, const std::string& message);
68 
69  void init_map()
70  {
71  set_cmd_prefix("/");
73  _("Send a query to the server. Without arguments the server"
74  " should tell you the available commands."));
75  register_alias("query", "q");
77  _("Ban and kick a player or observer. If he is not in the"
78  " game but on the server he will only be banned."), _("<nickname>"));
80  _("Unban a user. He does not have to be in the game but on"
81  " the server."), _("<nickname>"));
83  _("Kick a player or observer."), _("<nickname>"));
85  _("Mute an observer. Without an argument displays the mute status."), _("<nickname>"));
87  _("Unmute an observer. Without an argument unmutes everyone."), _("<nickname>"));
89  _("Mute/Unmute all observers. (toggles)"), "");
91  "");
93  _("Report abuse, rule violations, etc. to the server moderators. "
94  "Make sure to mention relevant nicknames, etc."), "");
95  register_alias("report", "adminmsg"); // deprecated
97  _("Send an emotion or personal action in chat."), _("<message>"));
98  register_alias("emote", "me");
100  _("Sends a private message. "
101  "You cannot send private messages to players in a running game you observe or play in."),
102  _("<nickname> <message>"));
103  register_alias("whisper", "msg");
104  register_alias("whisper", "m");
106  _("Change the log level of a log domain."), _("<level> <domain>"));
108  _("Add a nickname to your ignores list."), _("<nickname>"));
110  _("Add a nickname to your friends list."), _("<nickname>"));
112  _("Remove a nickname from your ignores or friends list."), _("<nickname>"));
114  _("Display version information."));
116  _("Request information about a nickname."), _("<nickname>"));
118  _("Join a room."), _("<room>"));
119  register_alias("join", "j");
121  _("Part a room."), _("<room>"));
123  _("List room members."), _("<room>"));
125  _("List available rooms."));
127  _("Room message."), _("<room> <msg>"));
129  _("Room query."), _("<room> <type> [value]"));
130  register_alias("room_query", "rq");
131  }
132 private:
135 };
136 
137 }
void do_info()
Request information about a user from the server.
void print(const std::string &title, const std::string &message)
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:91
map_command_handler< chat_command_handler > map
virtual void register_alias(const std::string &to_cmd, const std::string &cmd)
Handling of system events.
Definition: manager.hpp:41
std::string get_flags_description() const
std::string get_command_flags_description(const map_command_handler< chat_command_handler >::command &c) const
chat_command_handler(chat_handler &chathandler, bool allies_only)
bool is_enabled(const map_command_handler< chat_command_handler >::command &c) const
virtual void register_command(const std::string &cmd, command_handler h, const std::string &help="", const std::string &usage="", const std::string &flags="")
mock_char c