示例#1
0
void tchatbox::send_chat_message(const std::string& message,
	bool /*allies_only*/)
{
	::config c = config_of("message", config_of("message", message)("sender", preferences::login()));
	add_chat_message(time(nullptr), preferences::login(), 0, message);

	if(wesnothd_connection_) {
		wesnothd_connection_->send_data(c);
	}
}
示例#2
0
void tlobby_main::send_chat_message(const std::string& message,
									bool /*allies_only*/)
{
	config data, msg;
	msg["message"] = message;
	msg["sender"] = preferences::login();
	data.add_child("message", msg);

	add_chat_message(time(nullptr), preferences::login(), 0, message); // local
																	// echo
	wesnothd_connection_.send_data(data);
}
示例#3
0
/**
* Change the log level of a log domain.
*
* @param data string of the form: "@<level@> @<domain@>"
*/
void chat_handler::change_logging(const std::string& data) {
	const std::string::const_iterator j =
		std::find(data.begin(), data.end(), ' ');
	if (j == data.end()) return;
	const std::string level(data.begin(), j);
	const std::string domain(j + 1, data.end());
	int severity;
	if (level == "error") severity = lg::err().get_severity();
	else if (level == "warning") severity = lg::warn().get_severity();
	else if (level == "info") severity = lg::info().get_severity();
	else if (level == "debug") severity = lg::debug().get_severity();
	else {
		utils::string_map symbols;
		symbols["level"] = level;
		const std::string& msg =
			vgettext("Unknown debug level: '$level'.", symbols);
		ERR_NG << msg << std::endl;
		add_chat_message(time(nullptr), _("error"), 0, msg);
		return;
	}
	if (!lg::set_log_domain_severity(domain, severity)) {
		utils::string_map symbols;
		symbols["domain"] = domain;
		const std::string& msg =
			vgettext("Unknown debug domain: '$domain'.", symbols);
		ERR_NG << msg << std::endl;
		add_chat_message(time(nullptr), _("error"), 0, msg);
		return;
	}
	else {
		utils::string_map symbols;
		symbols["level"] = level;
		symbols["domain"] = domain;
		const std::string& msg =
			vgettext("Switched domain: '$domain' to level: '$level'.", symbols);
		LOG_NG << msg << "\n";
		add_chat_message(time(nullptr), "log", 0, msg);
	}
}
示例#4
0
void chat_handler::add_chat_room_message_received(const std::string &room,
	const std::string &speaker, const std::string &message)
{
	add_chat_message(time(nullptr), room + ": " + speaker, 0, message, events::chat_handler::MESSAGE_PRIVATE);
}
示例#5
0
void chat_handler::add_whisper_received(const std::string& sender, const std::string& message)
{
	utils::string_map symbols;
	symbols["sender"] = sender;
	add_chat_message(time(nullptr), VGETTEXT("whisper: $sender", symbols), 0, message);
}
示例#6
0
void chat_handler::add_whisper_sent(const std::string& receiver, const std::string& message)
{
	utils::string_map symbols;
	symbols["receiver"] = receiver;
	add_chat_message(time(nullptr), VGETTEXT("whisper to $receiver", symbols), 0, message);
}