changeset 847:a23b7b574ed2

irccd: rename [format] section to [templates], closes #1671
author David Demelier <markand@malikania.fr>
date Wed, 10 Jul 2019 20:10:00 +0200
parents dcef68d82fd3
children 800b025f9842
files CHANGES.md MIGRATING.md libirccd-daemon/irccd/daemon/bot.cpp libirccd-daemon/irccd/daemon/bot.hpp libirccd-daemon/irccd/daemon/plugin.cpp libirccd-daemon/irccd/daemon/plugin.hpp libirccd-daemon/irccd/daemon/plugin_service.cpp libirccd-daemon/irccd/daemon/plugin_service.hpp libirccd-js/irccd/js/plugin.cpp libirccd-js/irccd/js/plugin.hpp libirccd-js/irccd/js/plugin_api.cpp libirccd-test/irccd/test/broken_plugin.cpp libirccd-test/irccd/test/broken_plugin.hpp libirccd-test/irccd/test/mock_plugin.cpp libirccd-test/irccd/test/mock_plugin.hpp man/irccd-api.7 man/irccd.conf.5 plugins/hangman/hangman.js plugins/history/history.js plugins/joke/joke.js plugins/links/links.cpp plugins/links/links.hpp plugins/logger/logger.7 plugins/logger/logger.js plugins/plugin/plugin.js plugins/roulette/roulette.7 plugins/roulette/roulette.js plugins/tictactoe/tictactoe.js tests/src/plugins/hangman/main.cpp tests/src/plugins/history/main.cpp tests/src/plugins/joke/main.cpp tests/src/plugins/logger/main.cpp tests/src/plugins/plugin/main.cpp tests/src/plugins/tictactoe/main.cpp
diffstat 34 files changed, 152 insertions(+), 149 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.md	Wed Jul 10 13:39:20 2019 +0200
+++ b/CHANGES.md	Wed Jul 10 20:10:00 2019 +0200
@@ -14,7 +14,8 @@
 - Local transports support SSL (#939),
 - The origin in rule is now first class value (#947),
 - New option `ipv4` in `[transport]` (#945),
-- New option `ipv4` in `[server]` (#945).
+- New option `ipv4` in `[server]` (#945),
+- Section `[format]` is renamed to `[templates]` (#1671).
 
 irccdctl:
 
--- a/MIGRATING.md	Wed Jul 10 13:39:20 2019 +0200
+++ b/MIGRATING.md	Wed Jul 10 20:10:00 2019 +0200
@@ -14,6 +14,8 @@
 - The option `reconnect-timeout` has been renamed to `auto-reconnect-delay`.
 - The section `[identity]` has been removed, instead move those values inside
   each server in their `[server]` section.
+- The section `[format]` and their respective plugin counterparts are renamed to
+  `[templates]`.
 
 Irccdctl
 --------
--- a/libirccd-daemon/irccd/daemon/bot.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/bot.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -36,7 +36,7 @@
 
 namespace {
 
-class format_filter : public logger::filter {
+class template_filter : public logger::filter {
 private:
 	std::string info_;
 	std::string warning_;
@@ -48,7 +48,7 @@
 	             std::string_view) const -> std::string;
 
 public:
-	format_filter(std::string info, std::string warning, std::string debug) noexcept;
+	template_filter(std::string info, std::string warning, std::string debug) noexcept;
 
 	auto pre_debug(std::string_view,
 	               std::string_view,
@@ -63,7 +63,7 @@
 	                 std::string_view) const -> std::string override;
 };
 
-auto format_filter::convert(const std::string& tmpl,
+auto template_filter::convert(const std::string& tmpl,
                             std::string_view category,
                             std::string_view component,
                             std::string_view message) const -> std::string
@@ -82,28 +82,28 @@
 	return string_util::format(tmpl, params);
 }
 
-format_filter::format_filter(std::string info, std::string warning, std::string debug) noexcept
+template_filter::template_filter(std::string info, std::string warning, std::string debug) noexcept
 	: info_(std::move(info))
 	, warning_(std::move(warning))
 	, debug_(std::move(debug))
 {
 }
 
-auto format_filter::pre_debug(std::string_view category,
+auto template_filter::pre_debug(std::string_view category,
                               std::string_view component,
                               std::string_view message) const -> std::string
 {
 	return convert(debug_, category, component, message);
 }
 
-auto format_filter::pre_info(std::string_view category,
+auto template_filter::pre_info(std::string_view category,
                              std::string_view component,
                              std::string_view message) const -> std::string
 {
 	return convert(info_, category, component, message);
 }
 
-auto format_filter::pre_warning(std::string_view category,
+auto template_filter::pre_warning(std::string_view category,
                                 std::string_view component,
                                 std::string_view message) const -> std::string
 {
@@ -170,14 +170,14 @@
 	}
 }
 
-void bot::load_formats()
+void bot::load_templates()
 {
-	const auto sc = config_.get("format");
+	const auto sc = config_.get("templates");
 
 	if (sc.empty())
 		return;
 
-	filter_ = std::make_unique<format_filter>(
+	filter_ = std::make_unique<template_filter>(
 		sc.get("info").get_value(),
 		sc.get("warning").get_value(),
 		sc.get("debug").get_value()
@@ -264,9 +264,9 @@
 	 *    loading errors.
 	 */
 
-	// [logs] and [format] sections.
+	// [logs] and [templates] sections.
 	load_logs();
-	load_formats();
+	load_templates();
 
 	if (!loaded_)
 		sink_->info("irccd", "") << "loading configuration from " << config_.get_path() << std::endl;
--- a/libirccd-daemon/irccd/daemon/bot.hpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/bot.hpp	Wed Jul 10 20:10:00 2019 +0200
@@ -85,7 +85,7 @@
 	void load_logs_file(const ini::section&);
 	void load_logs_syslog();
 	void load_logs();
-	void load_formats();
+	void load_templates();
 
 public:
 	/**
--- a/libirccd-daemon/irccd/daemon/plugin.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/plugin.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -70,12 +70,12 @@
 {
 }
 
-auto plugin::get_formats() const -> map
+auto plugin::get_templates() const -> map
 {
 	return {};
 }
 
-void plugin::set_formats(const map&)
+void plugin::set_templates(const map&)
 {
 }
 
--- a/libirccd-daemon/irccd/daemon/plugin.hpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/plugin.hpp	Wed Jul 10 20:10:00 2019 +0200
@@ -63,7 +63,7 @@
 	/**
 	 * Map for key/value pairs.
 	 *
-	 * Used in options, formats and paths.
+	 * Used in options, templates and paths.
 	 */
 	using map = std::unordered_map<std::string, std::string>;
 
@@ -141,18 +141,18 @@
 	virtual void set_options(const map& map);
 
 	/**
-	 * Get all formats.
+	 * Get all templates.
 	 *
-	 * \return formats
+	 * \return the templates
 	 */
-	virtual auto get_formats() const -> map;
+	virtual auto get_templates() const -> map;
 
 	/**
-	 * Set all formats.
+	 * Set all templates.
 	 *
-	 * \param map the formats
+	 * \param map the templates
 	 */
-	virtual void set_formats(const map& map);
+	virtual void set_templates(const map& map);
 
 	/**
 	 * Get all paths.
--- a/libirccd-daemon/irccd/daemon/plugin_service.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/plugin_service.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -114,7 +114,7 @@
 	return to_map(bot_.get_config(), str(format("plugin.%1%") % id));
 }
 
-auto plugin_service::get_formats(std::string_view id) -> plugin::map
+auto plugin_service::get_templates(std::string_view id) -> plugin::map
 {
 	return to_map(bot_.get_config(), str(format("format.%1%") % id));
 }
@@ -203,7 +203,7 @@
 
 	try {
 		plugin->set_options(get_options(id));
-		plugin->set_formats(get_formats(id));
+		plugin->set_templates(get_templates(id));
 		plugin->set_paths(get_paths(id));
 	} catch (...) {
 		throw plugin_error(plugin_error::exec_error, id);
@@ -267,7 +267,7 @@
 		// Reload the plugin if already loaded.
 		if (p) {
 			p->set_options(get_options(id));
-			p->set_formats(get_formats(id));
+			p->set_templates(get_templates(id));
 			p->set_paths(get_paths(id));
 		} else {
 			try {
--- a/libirccd-daemon/irccd/daemon/plugin_service.hpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-daemon/irccd/daemon/plugin_service.hpp	Wed Jul 10 20:10:00 2019 +0200
@@ -136,12 +136,12 @@
 	auto get_options(std::string_view id) -> plugin::map;
 
 	/**
-	 * Get the formats for the specified plugin.
+	 * Get the templates for the specified plugin.
 	 *
 	 * \param id the plugin id
 	 * \return the formats
 	 */
-	auto get_formats(std::string_view id) -> plugin::map;
+	auto get_templates(std::string_view id) -> plugin::map;
 
 	/**
 	 * Get the paths for the specified plugin.
--- a/libirccd-js/irccd/js/plugin.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-js/irccd/js/plugin.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -143,11 +143,11 @@
 	duk::stack_guard sa(context_);
 
 	/*
-	 * Create two special tables for configuration and formats, they are
+	 * Create two special tables for configuration and templates, they are
 	 * referenced later as
 	 *
 	 *   - Irccd.Plugin.config
-	 *   - Irccd.Plugin.format
+	 *   - Irccd.Plugin.templates
 	 *   - Irccd.Plugin.paths
 	 *
 	 * In plugin_module.cpp.
@@ -155,7 +155,7 @@
 	duk_push_object(context_);
 	duk_put_global_string(context_, config_property.data());
 	duk_push_object(context_);
-	duk_put_global_string(context_, format_property.data());
+	duk_put_global_string(context_, templates_property.data());
 	duk_push_object(context_);
 	duk_put_global_string(context_, paths_property.data());
 
@@ -205,14 +205,14 @@
 	set_table(context_, config_property, map);
 }
 
-auto plugin::get_formats() const -> map
+auto plugin::get_templates() const -> map
 {
-	return get_table(context_, format_property);
+	return get_table(context_, templates_property);
 }
 
-void plugin::set_formats(const map& map)
+void plugin::set_templates(const map& map)
 {
-	set_table(context_, format_property, map);
+	set_table(context_, templates_property, map);
 }
 
 auto plugin::get_paths() const -> map
--- a/libirccd-js/irccd/js/plugin.hpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-js/irccd/js/plugin.hpp	Wed Jul 10 20:10:00 2019 +0200
@@ -49,9 +49,9 @@
 	static inline const std::string_view config_property{DUK_HIDDEN_SYMBOL("config")};
 
 	/**
-	 * Global property where to read/write plugin formats (object).
+	 * Global property where to read/write plugin templates (object).
 	 */
-	static inline const std::string_view format_property{DUK_HIDDEN_SYMBOL("formats")};
+	static inline const std::string_view templates_property{DUK_HIDDEN_SYMBOL("templates")};
 
 	/**
 	 * Global property where paths are defined (object).
@@ -130,14 +130,14 @@
 	void set_options(const map& map) override;
 
 	/**
-	 * \copydoc daemon::plugin::get_formats
+	 * \copydoc daemon::plugin::get_templates
 	 */
-	auto get_formats() const -> map override;
+	auto get_templates() const -> map override;
 
 	/**
-	 * \copydoc daemon::plugin::set_formats
+	 * \copydoc daemon::plugin::set_templates
 	 */
-	void set_formats(const map& map) override;
+	void set_templates(const map& map) override;
 
 	/**
 	 * \copydoc daemon::plugin::get_paths
--- a/libirccd-js/irccd/js/plugin_api.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-js/irccd/js/plugin_api.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -52,11 +52,11 @@
  * set
  * ------------------------------------------------------------------
  *
- * This setter is used to replace the Irccd.Plugin.(config|format|paths)
+ * This setter is used to replace the Irccd.Plugin.(config|templates|paths)
  * property when the plugin assign a new one.
  *
  * Because the plugin configuration always has higher priority, when a new
- * object is assigned to 'config' or to the 'format' property, the plugin
+ * object is assigned to 'config' or to the 'templates' property, the plugin
  * configuration is merged to the assigned one, adding or replacing any values.
  *
  * Example:
@@ -107,7 +107,7 @@
  * get
  * ------------------------------------------------------------------
  *
- * Get the Irccd.Plugin.(config|format|paths) property.
+ * Get the Irccd.Plugin.(config|templates|paths) property.
  */
 auto get(duk_context* ctx, std::string_view name) -> duk_ret_t
 {
@@ -139,32 +139,32 @@
 }
 
 /*
- * set_format
+ * set_template
  * ------------------------------------------------------------------
  *
- * Wrap setter for Irccd.Plugin.format property.
+ * Wrap setter for Irccd.Plugin.templates property.
  */
-auto set_format(duk_context* ctx) -> duk_ret_t
+auto set_template(duk_context* ctx) -> duk_ret_t
 {
-	return set(ctx, plugin::format_property);
+	return set(ctx, plugin::templates_property);
 }
 
 /*
- * get_format
+ * get_template
  * ------------------------------------------------------------------
  *
- * Wrap getter for Irccd.Plugin.format property.
+ * Wrap getter for Irccd.Plugin.templates property.
  */
-auto get_format(duk_context* ctx) -> duk_ret_t
+auto get_template(duk_context* ctx) -> duk_ret_t
 {
-	return get(ctx, plugin::format_property);
+	return get(ctx, plugin::templates_property);
 }
 
 /*
  * set_paths
  * ------------------------------------------------------------------
  *
- * Wrap setter for Irccd.Plugin.format property.
+ * Wrap setter for Irccd.Plugin.paths property.
  */
 auto set_paths(duk_context* ctx) -> duk_ret_t
 {
@@ -175,7 +175,7 @@
  * get_paths
  * ------------------------------------------------------------------
  *
- * Wrap getter for Irccd.Plugin.format property.
+ * Wrap getter for Irccd.Plugin.paths property.
  */
 auto get_paths(duk_context* ctx) -> duk_ret_t
 {
@@ -403,13 +403,13 @@
 	duk_push_c_function(plugin.get_context(), set_config, 1);
 	duk_def_prop(plugin.get_context(), -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER);
 
-	// 'format' property.
-	duk_push_string(plugin.get_context(), "format");
-	duk_push_c_function(plugin.get_context(), get_format, 0);
-	duk_push_c_function(plugin.get_context(), set_format, 1);
+	// 'templates' property.
+	duk_push_string(plugin.get_context(), "templates");
+	duk_push_c_function(plugin.get_context(), get_template, 0);
+	duk_push_c_function(plugin.get_context(), set_template, 1);
 	duk_def_prop(plugin.get_context(), -4, DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER);
 
-	// 'format' property.
+	// 'paths' property.
 	duk_push_string(plugin.get_context(), "paths");
 	duk_push_c_function(plugin.get_context(), get_paths, 0);
 	duk_push_c_function(plugin.get_context(), set_paths, 1);
--- a/libirccd-test/irccd/test/broken_plugin.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-test/irccd/test/broken_plugin.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -74,12 +74,12 @@
 	throw std::runtime_error("broken");
 }
 
-auto broken_plugin::get_formats() const -> map
+auto broken_plugin::get_templates() const -> map
 {
 	throw std::runtime_error("broken");
 }
 
-void broken_plugin::set_formats(const map&)
+void broken_plugin::set_templates(const map&)
 {
 	throw std::runtime_error("broken");
 }
--- a/libirccd-test/irccd/test/broken_plugin.hpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-test/irccd/test/broken_plugin.hpp	Wed Jul 10 20:10:00 2019 +0200
@@ -71,14 +71,14 @@
 	void set_options(const map& map) override;
 
 	/**
-	 * \copydoc daemon::plugin::get_formats
+	 * \copydoc daemon::plugin::get_templates
 	 */
-	auto get_formats() const -> map override;
+	auto get_templates() const -> map override;
 
 	/**
-	 * \copydoc daemon::plugin::set_formats
+	 * \copydoc daemon::plugin::set_templates
 	 */
-	void set_formats(const map& map) override;
+	void set_templates(const map& map) override;
 
 	/**
 	 * \copydoc daemon::plugin::get_paths
--- a/libirccd-test/irccd/test/mock_plugin.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-test/irccd/test/mock_plugin.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -88,18 +88,18 @@
 	options_ = map;
 }
 
-auto mock_plugin::get_formats() const -> map
+auto mock_plugin::get_templates() const -> map
 {
-	push("get_formats");
+	push("get_templates");
 
-	return formats_;
+	return templates_;
 }
 
-void mock_plugin::set_formats(const map& map)
+void mock_plugin::set_templates(const map& map)
 {
-	push("set_formats", { map });
+	push("set_templates", { map });
 
-	formats_ = map;
+	templates_ = map;
 }
 
 auto mock_plugin::get_paths() const -> map
--- a/libirccd-test/irccd/test/mock_plugin.hpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/libirccd-test/irccd/test/mock_plugin.hpp	Wed Jul 10 20:10:00 2019 +0200
@@ -36,7 +36,7 @@
 class mock_plugin : public daemon::plugin, public mock {
 private:
 	map options_;
-	map formats_;
+	map templates_;
 	map paths_;
 
 public:
@@ -78,14 +78,14 @@
 	void set_options(const map& map) override;
 
 	/**
-	 * \copydoc daemon::plugin::get_formats
+	 * \copydoc daemon::plugin::get_templates
 	 */
-	auto get_formats() const -> map override;
+	auto get_templates() const -> map override;
 
 	/**
-	 * \copydoc daemon::plugin::set_formats
+	 * \copydoc daemon::plugin::set_templates
 	 */
-	void set_formats(const map& map) override;
+	void set_templates(const map& map) override;
 
 	/**
 	 * \copydoc daemon::plugin::get_paths
--- a/man/irccd-api.7	Wed Jul 10 13:39:20 2019 +0200
+++ b/man/irccd-api.7	Wed Jul 10 20:10:00 2019 +0200
@@ -1206,7 +1206,7 @@
 section.
 .It Va templates No (Object)
 Contains the
-.Va [format.<name>]
+.Va [templates.<name>]
 section.
 .El
 .\" }}} !Constants
--- a/man/irccd.conf.5	Wed Jul 10 13:39:20 2019 +0200
+++ b/man/irccd.conf.5	Wed Jul 10 20:10:00 2019 +0200
@@ -117,11 +117,11 @@
 .Pp
 Note: syslog is not available on all platforms.
 .El
-.\" [format]
-.Ss format
-The format section let you change the irccd's output. It uses the templates
+.\" [templates]
+.Ss templates
+The templates section let you change the irccd's output. It uses the templates
 system (see
-.Xr irccd-format 7
+.Xr irccd-templates 7
 for more information about templates)
 .Pp
 Only one keyword is defined, message which contains the message that irccd
--- a/plugins/hangman/hangman.js	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/hangman/hangman.js	Wed Jul 10 20:10:00 2019 +0200
@@ -37,7 +37,7 @@
 Plugin.config["collaborative"] = "true";
 
 // Formats.
-Plugin.format = {
+Plugin.templates = {
 	"asked":        "#{nickname}, '#{letter}' was already asked.",
 	"dead":         "#{nickname}, fail the word was: #{word}.",
 	"found":        "#{nickname}, nice! the word is now #{word}",
@@ -284,7 +284,7 @@
 	switch (st) {
 	case "found":
 		kw.word = game.formatWord();
-		server.message(channel, Util.format(Plugin.format["found"], kw));
+		server.message(channel, Util.format(Plugin.templates["found"], kw));
 		break;
 	case "wrong-letter":
 	case "wrong-player":
@@ -292,12 +292,12 @@
 		kw.word = proposition;
 	case "asked":
 		kw.letter = String.fromCharCode(proposition);
-		server.message(channel, Util.format(Plugin.format[st], kw));
+		server.message(channel, Util.format(Plugin.templates[st], kw));
 		break;
 	case "dead":
 	case "win":
 		kw.word = game.word;
-		server.message(channel, Util.format(Plugin.format[st], kw));
+		server.message(channel, Util.format(Plugin.templates[st], kw));
 
 		// Remove the game.
 		Hangman.remove(game);
@@ -331,7 +331,7 @@
 
 		if (list.length === 0 || String(list[0]).length === 0) {
 			kw.word = game.formatWord();
-			server.message(channel, Util.format(Plugin.format["running"], kw));
+			server.message(channel, Util.format(Plugin.templates["running"], kw));
 		} else {
 			var word = String(list[0]);
 
@@ -342,7 +342,7 @@
 		game = Hangman.create(server, channel);
 		game.query = isquery;
 		kw.word = game.formatWord();
-		server.message(channel, Util.format(Plugin.format["start"], kw));
+		server.message(channel, Util.format(Plugin.templates["start"], kw));
 	}
 
 	return game;
--- a/plugins/history/history.js	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/history/history.js	Wed Jul 10 20:10:00 2019 +0200
@@ -33,7 +33,7 @@
 var Server = Irccd.Server;
 var Util = Irccd.Util;
 
-Plugin.format = {
+Plugin.templates = {
 	"error":        "#{nickname}, I'm sorry, something went wrong.",
 	"seen":         "#{nickname}, I've seen #{target} for the last time the %d-%m-%Y %H:%M",
 	"said":         "#{nickname}, #{target} said on %d-%m-%Y %H:%M: #{message}",
@@ -132,12 +132,12 @@
 	};
 
 	if (args.length !== 2 || args[0].length === 0 || args[1].length === 0) {
-		server.message(channel, Util.format(Plugin.format.usage, kw));
+		server.message(channel, Util.format(Plugin.templates.usage, kw));
 		return;
 	}
 
 	if (args[0] !== "seen" && args[0] !== "said") {
-		server.message(channel, Util.format(Plugin.format.usage, kw));
+		server.message(channel, Util.format(Plugin.templates.usage, kw));
 		return;
 	}
 
@@ -152,16 +152,16 @@
 		kw.target = args[1];
 
 		if (!info) {
-			server.message(channel, Util.format(Plugin.format.unknown, kw));
+			server.message(channel, Util.format(Plugin.templates.unknown, kw));
 			return;
 		}
 
 		kw.date = info.timestamp;
 		kw.message = info.message ? info.message : "";
 
-		server.message(channel, Util.format(Plugin.format[args[0] == "seen" ? "seen" : "said"], kw));
+		server.message(channel, Util.format(Plugin.templates[args[0] == "seen" ? "seen" : "said"], kw));
 	} catch (e) {
-		server.message(channel, Util.format(Plugin.format["error"], kw));
+		server.message(channel, Util.format(Plugin.templates["error"], kw));
 	}
 }
 
--- a/plugins/joke/joke.js	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/joke/joke.js	Wed Jul 10 20:10:00 2019 +0200
@@ -32,7 +32,7 @@
 var Util = Irccd.Util;
 
 Plugin.config["max-list-lines"] = 5;
-Plugin.format["error"] = "#{nickname}: no jokes available";
+Plugin.templates["error"] = "#{nickname}: no jokes available";
 
 /**
  * Map of server/channel to list of jokes.
@@ -171,7 +171,7 @@
 			table[i] = load(server, channel);
 		} catch (e) {
 			Logger.warning(e.message);
-			server.message(channel, Util.format(Plugin.format.error, {
+			server.message(channel, Util.format(Plugin.templates.error, {
 				server: server.toString(),
 				channel: channel,
 				origin: origin,
--- a/plugins/links/links.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/links/links.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -69,7 +69,7 @@
 			conf_timeout = *v;
 }
 
-void links_plugin::set_formats(const map& formats)
+void links_plugin::set_templates(const map& formats)
 {
 	if (const auto it = formats.find("info"); it != formats.end())
 		format_info = it->second;
--- a/plugins/links/links.hpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/links/links.hpp	Wed Jul 10 20:10:00 2019 +0200
@@ -76,9 +76,9 @@
 	void set_options(const map&) override;
 
 	/**
-	 * \copydoc plugin::set_formats
+	 * \copydoc plugin::set_templates
 	 */
-	void set_formats(const map&) override;
+	void set_templates(const map&) override;
 
 	/**
 	 * \copydoc plugin::handle_message
--- a/plugins/logger/logger.7	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/logger/logger.7	Wed Jul 10 20:10:00 2019 +0200
@@ -80,25 +80,25 @@
 .It Va join
 Format when someone joins a channel.
 .It Va kick
-Format when someone has been kicked. Keywords: 
+Format when someone has been kicked. Keywords:
 .Em reason , target .
 .It Va me
-Format for emote actions. Keywords: 
+Format for emote actions. Keywords:
 .Em message .
 .It Va message
-Format for channel messages. Keywords: 
+Format for channel messages. Keywords:
 .Em message .
 .It Va mode
-Format for user mode change. Keywords: 
+Format for user mode change. Keywords:
 .Em mode , limit , user , mask .
 .It Va notice
-Format on private notices. Keywords: 
+Format on private notices. Keywords:
 .Em message .
 .It Va part
-Format when someone leaves a channel. Keywords: 
+Format when someone leaves a channel. Keywords:
 .Em reason .
 .It Va topic
-Format when a topic is changed. Keywords: 
+Format when a topic is changed. Keywords:
 .Em topic .
 .El
 .Pp
@@ -111,7 +111,7 @@
 [plugin.logger]
 path = "/var/log/irccd/#{server}/%y/%m/%d/#{channel}.txt"
 
-[format.logger]
+[templates.logger]
 join = "user #{nickname} joined #{channel}"
 .Ed
 .\" SEE ALSO
--- a/plugins/logger/logger.js	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/logger/logger.js	Wed Jul 10 20:10:00 2019 +0200
@@ -33,9 +33,9 @@
 var Util = Irccd.Util;
 
 /**
- * All available formats.
+ * All available templates.
  */
-Plugin.format = {
+Plugin.templates = {
 	"join":         "%H:%M:%S >> #{nickname} joined #{channel}",
 	"kick":         "%H:%M:%S :: #{target} has been kicked by #{nickname} [reason: #{reason}]",
 	"me":           "%H:%M:%S * #{nickname} #{message}",
@@ -75,7 +75,7 @@
 
 	Logger.debug("opening: " + path);
 
-	var str = Util.format(Plugin.format[fmt], args);
+	var str = Util.format(Plugin.templates[fmt], args);
 	var file = new File(path, "a");
 
 	file.write(str + "\n");
--- a/plugins/plugin/plugin.js	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/plugin/plugin.js	Wed Jul 10 20:10:00 2019 +0200
@@ -29,7 +29,7 @@
 var Util = Irccd.Util;
 var Plugin = Irccd.Plugin;
 
-Plugin.format = {
+Plugin.templates = {
 	"usage":        "#{nickname}, usage: #{command} list | info plugin",
 	"info":         "#{nickname}, #{name}: #{summary}, version #{version} by #{author} (#{license} license).",
 	"not-found":    "#{nickname}, plugin #{name} does not exist.",
@@ -81,7 +81,7 @@
 		}
 
 		if (!query && maxl > 0 && lines.length > maxl) {
-			server.message(target, Util.format(Plugin.format["too-long"], kw));
+			server.message(target, Util.format(Plugin.templates["too-long"], kw));
 		} else {
 			for (var i = 0; i < lines.length; ++i) {
 				server.message(target, lines[i]);
@@ -103,16 +103,16 @@
 			kw.summary = info.summary;
 			kw.version = info.version;
 
-			str = Util.format(Plugin.format["info"], kw);
+			str = Util.format(Plugin.templates["info"], kw);
 		} else
-			str = Util.format(Plugin.format["not-found"], kw);
+			str = Util.format(Plugin.templates["not-found"], kw);
 
 		server.message(target, str);
 	},
 
 	usage: function (server, origin, target)
 	{
-		server.message(target, Util.format(Plugin.format["usage"], commands.keywords(server, target, origin)));
+		server.message(target, Util.format(Plugin.templates["usage"], commands.keywords(server, target, origin)));
 	},
 
 	execute: function (server, origin, target, message, query)
--- a/plugins/roulette/roulette.7	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/roulette/roulette.7	Wed Jul 10 20:10:00 2019 +0200
@@ -75,7 +75,7 @@
 .Sh EXAMPLES
 Example of configuration file:
 .Bd -literal
-[format.roulette]
+[templates.roulette]
 lucky = "#{nickname} you're gonna get shot"
 shot = "BIM"
 .Ed
--- a/plugins/roulette/roulette.js	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/roulette/roulette.js	Wed Jul 10 20:10:00 2019 +0200
@@ -34,7 +34,7 @@
 /**
  * Formats for writing.
  */
-Plugin.format = {
+Plugin.templates = {
 	"lucky":        "#{nickname}, you're lucky this time",
 	"shot":         "HEADSHOT"
 };
@@ -110,10 +110,10 @@
 		game = Gun.create(server, channel);
 
 	if (game.shot()) {
-		server.kick(Util.splituser(origin), channel, Util.format(Plugin.format["shot"], kw));
+		server.kick(Util.splituser(origin), channel, Util.format(Plugin.templates["shot"], kw));
 		Gun.remove(game);
 	} else {
 		kw.count = (6 - game.index).toString();
-		server.message(channel, Util.format(Plugin.format["lucky"], kw));
+		server.message(channel, Util.format(Plugin.templates["lucky"], kw));
 	}
 }
--- a/plugins/tictactoe/tictactoe.js	Wed Jul 10 13:39:20 2019 +0200
+++ b/plugins/tictactoe/tictactoe.js	Wed Jul 10 20:10:00 2019 +0200
@@ -30,7 +30,7 @@
 var Util = Irccd.Util;
 
 // Formats.
-Plugin.format = {
+Plugin.templates = {
 	"draw":         "nobody won",
 	"invalid":      "#{nickname}, please select a valid opponent",
 	"running":      "#{nickname}, the game is already running",
@@ -194,11 +194,11 @@
 	this.server.message(this.channel, "3 " + this.grid[2].join(" "));
 
 	if (this.hasWinner())
-		this.server.message(this.channel, Util.format(Plugin.format.win, kw));
+		this.server.message(this.channel, Util.format(Plugin.templates.win, kw));
 	else if (this.hasDraw())
-		this.server.message(this.channel, Util.format(Plugin.format.draw, kw));
+		this.server.message(this.channel, Util.format(Plugin.templates.draw, kw));
 	else
-		this.server.message(this.channel, Util.format(Plugin.format.turn, kw));
+		this.server.message(this.channel, Util.format(Plugin.templates.turn, kw));
 }
 
 /**
@@ -229,7 +229,7 @@
 	var kw = Game.keywords(this.server, this.channel, origin);
 
 	if (this.grid[row][column] !== '.') {
-		this.server.message(this.channel, Util.format(Plugin.format.used, kw));
+		this.server.message(this.channel, Util.format(Plugin.templates.used, kw));
 		return false;
 	}
 
@@ -300,7 +300,7 @@
 
 	// Not a valid target? destroy the game.
 	if (list.indexOf(game.target) < 0)
-		server.message(channel, Util.format(Plugin.format.invalid,
+		server.message(channel, Util.format(Plugin.templates.invalid,
 			Game.keywords(server, channel, game.origin)));
 	else {
 		Game.map[id] = game;
@@ -316,9 +316,9 @@
 	var nickname = Util.splituser(origin);
 
 	if (Game.exists(server, channel))
-		server.message(channel, Util.format(Plugin.format.running, Game.keywords(server, channel, origin)));
+		server.message(channel, Util.format(Plugin.templates.running, Game.keywords(server, channel, origin)));
 	else if (target === "" || target === nickname || target === server.info().nickname)
-		server.message(channel, Util.format(Plugin.format.invalid, Game.keywords(server, channel, origin)));
+		server.message(channel, Util.format(Plugin.templates.invalid, Game.keywords(server, channel, origin)));
 	else
 		Game.postpone(server, channel, origin, message);
 }
--- a/tests/src/plugins/hangman/main.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/tests/src/plugins/hangman/main.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -40,7 +40,7 @@
 	hangman_test()
 		: js_plugin_fixture(PLUGIN_PATH)
 	{
-		plugin_->set_formats({
+		plugin_->set_templates({
 			{ "asked", "asked=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{letter}" },
 			{ "dead", "dead=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{word}" },
 			{ "found", "found=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{word}" },
@@ -327,7 +327,7 @@
 	};
 	std::unordered_set<unsigned> found;
 
-	plugin_->set_formats({
+	plugin_->set_templates({
 		{ "start", "#{word}" }
 	});
 
--- a/tests/src/plugins/history/main.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/tests/src/plugins/history/main.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -39,7 +39,7 @@
 	history_test()
 		: js_plugin_fixture(PLUGIN_PATH)
 	{
-		plugin_->set_formats({
+		plugin_->set_templates({
 			{ "error", "error=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}" },
 			{ "seen", "seen=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{target}:%H:%M" },
 			{ "said", "said=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{target}:#{message}:%H:%M" },
@@ -60,7 +60,7 @@
 
 BOOST_FIXTURE_TEST_SUITE(history_test_suite, history_test)
 
-BOOST_AUTO_TEST_CASE(format_error)
+BOOST_AUTO_TEST_CASE(template_error)
 {
 	load({{"file", CMAKE_CURRENT_SOURCE_DIR "/error.json"}});
 
@@ -72,7 +72,7 @@
 	BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "error=history:!history:test:#history:jean!jean@localhost:jean");
 }
 
-BOOST_AUTO_TEST_CASE(format_seen)
+BOOST_AUTO_TEST_CASE(template_seen)
 {
 	static const std::regex rule("seen=history:!history:test:#history:destructor!dst@localhost:destructor:jean:\\d{2}:\\d{2}");
 
@@ -88,7 +88,7 @@
 	BOOST_TEST(std::regex_match(std::any_cast<std::string>(cmd[1]), rule));
 }
 
-BOOST_AUTO_TEST_CASE(format_said)
+BOOST_AUTO_TEST_CASE(template_said)
 {
 	std::regex rule("said=history:!history:test:#history:destructor!dst@localhost:destructor:jean:hello:\\d{2}:\\d{2}");
 
@@ -104,7 +104,7 @@
 	BOOST_TEST(std::regex_match(std::any_cast<std::string>(cmd[1]), rule));
 }
 
-BOOST_AUTO_TEST_CASE(format_unknown)
+BOOST_AUTO_TEST_CASE(template_unknown)
 {
 	remove(CMAKE_CURRENT_BINARY_DIR "/unknown.json");
 	load({{ "file", CMAKE_CURRENT_BINARY_DIR "/unknown.json" }});
--- a/tests/src/plugins/joke/main.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/tests/src/plugins/joke/main.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -34,7 +34,7 @@
 	joke_test()
 		: js_plugin_fixture(PLUGIN_PATH)
 	{
-		plugin_->set_formats({
+		plugin_->set_templates({
 			{ "error", "error=#{server}:#{channel}:#{origin}:#{nickname}" }
 		});
 	}
--- a/tests/src/plugins/logger/main.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/tests/src/plugins/logger/main.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -50,7 +50,7 @@
 	{
 		remove(CMAKE_CURRENT_BINARY_DIR "/log.txt");
 
-		plugin_->set_formats({
+		plugin_->set_templates({
 			{ "join", "join=#{server}:#{channel}:#{origin}:#{nickname}" },
 			{ "kick", "kick=#{server}:#{channel}:#{origin}:#{nickname}:#{target}:#{reason}" },
 			{ "me", "me=#{server}:#{channel}:#{origin}:#{nickname}:#{message}" },
@@ -75,7 +75,7 @@
 
 BOOST_FIXTURE_TEST_SUITE(logger_test_suite, logger_test)
 
-BOOST_AUTO_TEST_CASE(format_join)
+BOOST_AUTO_TEST_CASE(template_join)
 {
 	load();
 
@@ -84,7 +84,7 @@
 	BOOST_REQUIRE_EQUAL("join=test:#staff:jean!jean@localhost:jean\n", last());
 }
 
-BOOST_AUTO_TEST_CASE(format_kick)
+BOOST_AUTO_TEST_CASE(template_kick)
 {
 	load();
 
@@ -93,7 +93,7 @@
 	BOOST_REQUIRE_EQUAL("kick=test:#staff:jean!jean@localhost:jean:badboy:please do not flood\n", last());
 }
 
-BOOST_AUTO_TEST_CASE(format_me)
+BOOST_AUTO_TEST_CASE(template_me)
 {
 	load();
 
@@ -102,7 +102,7 @@
 	BOOST_REQUIRE_EQUAL("me=test:#staff:jean!jean@localhost:jean:is drinking water\n", last());
 }
 
-BOOST_AUTO_TEST_CASE(format_message)
+BOOST_AUTO_TEST_CASE(template_message)
 {
 	load();
 
@@ -111,7 +111,7 @@
 	BOOST_REQUIRE_EQUAL("message=test:#staff:jean!jean@localhost:jean:hello guys\n", last());
 }
 
-BOOST_AUTO_TEST_CASE(format_mode)
+BOOST_AUTO_TEST_CASE(template_mode)
 {
 	load();
 
@@ -120,7 +120,7 @@
 	BOOST_REQUIRE_EQUAL("mode=test:jean!jean@localhost:chris:+i:l:u:m\n", last());
 }
 
-BOOST_AUTO_TEST_CASE(format_notice)
+BOOST_AUTO_TEST_CASE(template_notice)
 {
 	load();
 
@@ -129,7 +129,7 @@
 	BOOST_REQUIRE_EQUAL("notice=test:jean!jean@localhost:chris:tu veux voir mon chat ?\n", last());
 }
 
-BOOST_AUTO_TEST_CASE(format_part)
+BOOST_AUTO_TEST_CASE(template_part)
 {
 	load();
 
@@ -138,7 +138,7 @@
 	BOOST_REQUIRE_EQUAL("part=test:#staff:jean!jean@localhost:jean:too noisy here\n", last());
 }
 
-BOOST_AUTO_TEST_CASE(format_topic)
+BOOST_AUTO_TEST_CASE(template_topic)
 {
 	load();
 
--- a/tests/src/plugins/plugin/main.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/tests/src/plugins/plugin/main.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -76,7 +76,7 @@
 	{
 		bot_.get_plugins().add(std::make_shared<fake_plugin>("fake"));
 
-		plugin_->set_formats({
+		plugin_->set_templates({
 			{ "usage", "usage=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}" },
 			{ "info", "info=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{author}:#{license}:#{name}:#{summary}:#{version}" },
 			{ "not-found", "not-found=#{plugin}:#{command}:#{server}:#{channel}:#{origin}:#{nickname}:#{name}" },
@@ -88,7 +88,7 @@
 
 BOOST_FIXTURE_TEST_SUITE(test_fixture_suite, test_fixture)
 
-BOOST_AUTO_TEST_CASE(format_usage)
+BOOST_AUTO_TEST_CASE(template_usage)
 {
 	plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "" });
 
@@ -110,7 +110,7 @@
 	BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "usage=plugin:!plugin:test:#staff:jean!jean@localhost:jean");
 }
 
-BOOST_AUTO_TEST_CASE(format_info)
+BOOST_AUTO_TEST_CASE(template_info)
 {
 	plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "info fake" });
 
@@ -120,7 +120,7 @@
 	BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "info=plugin:!plugin:test:#staff:jean!jean@localhost:jean:jean:BEER:fake:Fake White Beer 2000:0.0.0.0.0.1");
 }
 
-BOOST_AUTO_TEST_CASE(format_not_found)
+BOOST_AUTO_TEST_CASE(template_not_found)
 {
 	plugin_->handle_command(bot_, { server_, "jean!jean@localhost", "#staff", "info doesnotexistsihope" });
 
@@ -130,7 +130,7 @@
 	BOOST_TEST(std::any_cast<std::string>(cmd[1]) == "not-found=plugin:!plugin:test:#staff:jean!jean@localhost:jean:doesnotexistsihope");
 }
 
-BOOST_AUTO_TEST_CASE(format_too_long)
+BOOST_AUTO_TEST_CASE(template_too_long)
 {
 	for (int i = 0; i < 100; ++i)
 		bot_.get_plugins().add(std::make_shared<fake_plugin>(str(format("plugin-n-%1%") % i)));
--- a/tests/src/plugins/tictactoe/main.cpp	Wed Jul 10 13:39:20 2019 +0200
+++ b/tests/src/plugins/tictactoe/main.cpp	Wed Jul 10 20:10:00 2019 +0200
@@ -38,7 +38,7 @@
 	test_fixture()
 		: js_plugin_fixture(PLUGIN_PATH)
 	{
-		plugin_->set_formats({
+		plugin_->set_templates({
 			{ "draw", "draw=#{channel}:#{command}:#{nickname}:#{plugin}:#{server}" },
 			{ "invalid", "invalid=#{channel}:#{command}:#{nickname}:#{origin}:#{plugin}:#{server}" },
 			{ "running", "running=#{channel}:#{command}:#{nickname}:#{origin}:#{plugin}:#{server}" },