mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 09:30:19 +00:00
Implemented the adminmsg command to allow players to send messages to currently available admins; fixes bug #9218: Wish: /adminmsg
This commit is contained in:
parent
e40612822f
commit
acfe2ebd7a
@ -9,7 +9,8 @@ Version 1.7.0-svn:
|
||||
* Changed AI Lifecycle handling. Console AI is now persistent between
|
||||
invocations.
|
||||
* Added AI Arena test map to test AIs in interactive mode ( ai_arena_small )
|
||||
* Changed interaction between default AI an Formula AI - made default AI not fallback to formula AI
|
||||
* Changed interaction between default AI an Formula AI - made default AI not
|
||||
fallback to formula AI
|
||||
* Editor2:
|
||||
* New feature: exporting of selection coordinates to system clipboard
|
||||
* Made auto terrain transition mode tri-state: on (editor2's on), partial
|
||||
@ -39,6 +40,10 @@ Version 1.7.0-svn:
|
||||
* Fixed word wrapping in CJK languages (patch #1140 from sylecn)
|
||||
* Multiplayer server:
|
||||
* Implemented automatic saving of game replays.
|
||||
* Implemented the adminmsg command to allow players to send messages to
|
||||
currently available admins. (FR #9218)
|
||||
* Savegames
|
||||
* Providing a new simpler interface for dealing with savegames
|
||||
* User interface:
|
||||
* Fixed bug #13257: Attack dialog always uses the active name of a weapon
|
||||
special
|
||||
@ -51,8 +56,6 @@ Version 1.7.0-svn:
|
||||
now (bug #13170)
|
||||
* Added a "preload" WML event type.
|
||||
* Added support for Lua scripts in WML event actions ([lua] tag)
|
||||
* Savegames
|
||||
* Providing a new simpler interface for dealing with savegames
|
||||
* Miscellaneous and bugfixes:
|
||||
* Fixed compilation with -D_GLIBCXX_PARALLEL
|
||||
* Fixed handling of floating-point WML constants on localized Windows
|
||||
|
@ -1234,7 +1234,8 @@ void game::save_replay() {
|
||||
<< "[replay]\n" << replay_commands << "[/replay]\n"
|
||||
<< "[replay_start]\n" << level_.output() << "[/replay_start]\n";
|
||||
|
||||
simple_wml::document replay(replay_data.str().c_str(), simple_wml::INIT_STATIC);
|
||||
std::string replay_data_str = replay_data.str();
|
||||
simple_wml::document replay(replay_data_str.c_str(), simple_wml::INIT_STATIC);
|
||||
|
||||
std::string filename(name.str());
|
||||
std::replace(filename.begin(), filename.end(), ' ', '_');
|
||||
|
@ -1216,12 +1216,13 @@ void server::process_query(const network::connection sock,
|
||||
}
|
||||
const simple_wml::string_span& command(query["type"]);
|
||||
std::ostringstream response;
|
||||
const std::string& help_msg = "Available commands are: help, games, metrics,"
|
||||
const std::string& help_msg = "Available commands are: adminmsg <msg>, help, games, metrics,"
|
||||
" motd, netstats [all], stats, status, wml.";
|
||||
// Commands a player may issue.
|
||||
if (command == "status") {
|
||||
response << process_command(command.to_string() + " " + pl->second.name(), pl->second.name());
|
||||
} else if (command == "games"
|
||||
} else if (command.to_string().find("adminmsg") == 0
|
||||
|| command == "games"
|
||||
|| command == "metrics"
|
||||
|| command == "motd"
|
||||
|| command == "netstats"
|
||||
@ -1292,10 +1293,11 @@ std::string server::process_command(const std::string& query, const std::string&
|
||||
const std::string command(query.begin(),i);
|
||||
std::string parameters = (i == query.end() ? "" : std::string(i+1,query.end()));
|
||||
utils::strip(parameters);
|
||||
const std::string& help_msg = "Available commands are: ban <mask> [<time>] <reason>,"
|
||||
" bans [deleted], clones, dul|deny_unregistered_login [yes|no],"
|
||||
" kick <mask> [<reason>], k[ick]ban <mask> [<time>] <reason>,"
|
||||
" help, games, metrics, netstats [all], [lobby]msg <message>, motd [<message>],"
|
||||
const std::string& help_msg = "Available commands are: adminmsg <msg>,"
|
||||
" ban <mask> [<time>] <reason>, bans [deleted], clones,"
|
||||
" dul|deny_unregistered_login [yes|no], kick <mask> [<reason>],"
|
||||
" k[ick]ban <mask> [<time>] <reason>, help, games, metrics,"
|
||||
" netstats [all], [lobby]msg <message>, motd [<message>],"
|
||||
" requests, stats, status [<mask>], searchlog <mask>, signout, unban <ipmask>";
|
||||
// Shutdown, restart and sample commands can only be issued via the socket.
|
||||
if (command == "shut_down") {
|
||||
@ -1361,6 +1363,19 @@ std::string server::process_command(const std::string& query, const std::string&
|
||||
out << network::get_bandwidth_stats_all();
|
||||
else
|
||||
out << network::get_bandwidth_stats(); // stats from previuos hour
|
||||
} else if (command == "adminmsg") {
|
||||
if (parameters == "") return "You must type a message.";
|
||||
LOG_SERVER << "Admin message: <" << issuer_name << "> " << parameters << "\n";
|
||||
if (admins_.size() < 1) return "Sorry, no admin available right now. But your message got logged.";
|
||||
|
||||
simple_wml::document data;
|
||||
simple_wml::node& msg = data.root().add_child("whisper");
|
||||
msg.set_attr_dup("sender", ("Admin message - " + issuer_name).c_str());
|
||||
msg.set_attr_dup("message", parameters.c_str());
|
||||
for (std::set<network::connection>::const_iterator i = admins_.begin(); i != admins_.end(); ++i) {
|
||||
send_doc(data, *i);
|
||||
}
|
||||
out << "Message delivered to " << admins_.size() << " admins.";
|
||||
} else if (command == "msg" || command == "lobbymsg") {
|
||||
if (parameters == "") {
|
||||
return "You must type a message.";
|
||||
|
Loading…
x
Reference in New Issue
Block a user