Mercurial > irccd
changeset 145:410f71eb9237
Plugin plugin: use new format section, #410
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 19 May 2016 22:21:54 +0200 |
parents | 5ed0c78a6785 |
children | 175bc5d41cc4 |
files | plugins/plugin/plugin.js plugins/plugin/plugin.md |
diffstat | 2 files changed, 39 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/plugin/plugin.js Thu May 19 22:03:53 2016 +0200 +++ b/plugins/plugin/plugin.js Thu May 19 22:21:54 2016 +0200 @@ -16,10 +16,11 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +// Modules. var Util = Irccd.Util; var Plugin = Irccd.Plugin; -/* Plugin information */ +// Plugin information. info = { author: "David Demelier <markand@malikania.fr>", license: "ISC", @@ -27,7 +28,7 @@ version: "@IRCCD_VERSION@" }; -var formats = { +Plugin.format = { "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.", @@ -37,7 +38,16 @@ var commands = { loadFormats: function () { - for (var key in formats) { + // --- DEPRECATED ----------------------------------- + // + // This code will be removed. + // + // Since: 2.1.0 + // Until: 3.0.0 + // Reason: new [format] section replaces it. + // + // -------------------------------------------------- + for (var key in Plugin.format) { var optname = "format-" + key; if (typeof (Plugin.config[optname]) !== "string") @@ -46,7 +56,7 @@ if (Plugin.config[optname].length === 0) Logger.warning("skipping empty '" + optname + "' format"); else - formats[key] = Plugin.config[optname]; + Plugin.format[key] = Plugin.config[optname]; } }, @@ -69,7 +79,7 @@ var str; if (!query && list.length >= 16) - str = Util.format(formats["too-long"], kw); + str = Util.format(Plugin.format["too-long"], kw); else str = list.join(" "); @@ -90,17 +100,16 @@ kw.summary = info.summary; kw.version = info.version; - str = Util.format(formats["info"], kw); - } else { - str = Util.format(formats["not-found"], kw); - } + str = Util.format(Plugin.format["info"], kw); + } else + str = Util.format(Plugin.format["not-found"], kw); server.message(target, str); }, usage: function (server, origin, target) { - server.message(target, Util.format(formats["usage"], commands.keywords(server, target, origin))); + server.message(target, Util.format(Plugin.format["usage"], commands.keywords(server, target, origin))); }, execute: function (server, origin, target, message, query)
--- a/plugins/plugin/plugin.md Thu May 19 22:03:53 2016 +0200 +++ b/plugins/plugin/plugin.md Thu May 19 22:21:54 2016 +0200 @@ -25,21 +25,30 @@ ## Configuration -You can use different formats. - The following options are available under the `[plugin.plugin]` section: - - **format-usage**: (string) message to show on invalid usage, - - **format-info**: (string) plugin information message to show, - - **format-not-found**: (string) message to show if a plugin does not exist, - - **format-too-long**: (string) message to show if the list of plugin is too long. +**Deprecated in irccd 2.1.0:** + + - **format-usage**: Use `[format.plugin] usage` instead, + - **format-info**: Use `[format.plugin] info` instead, + - **format-not-found**: Use `[format.plugin] not-found` instead, + - **format-too-long**: Use `[format.plugin] too-long` instead, + +## Formats + +The **plugin** plugin supports the following formats in `[format.plugin]` section: + + - **usage**: (string) message to show on invalid usage, + - **info**: (string) plugin information message to show, + - **not-found**: (string) message to show if a plugin does not exist, + - **too-long**: (string) message to show if the list of plugin is too long. ### Keywords supported The following keywords are supported: -| Format | Keywords | Notes | -|-------------------------|----------------------------------------------------|---------------------------------------------| -| (any) | channel, command, nickname, origin, plugin, server | | -| **format-info** | author, license, name, summary, version | the plugin information | -| **format-not-found** | name | the plugin name | +| Format | Keywords | Notes | +|---------------|----------------------------------------------------|---------------------------------------------| +| (any) | channel, command, nickname, origin, plugin, server | | +| **info** | author, license, name, summary, version | the plugin information | +| **not-found** | name | the plugin name |