Mercurial > irccd
changeset 143:11113212576c
Plugin history: use new format section, #410
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 19 May 2016 21:17:50 +0200 |
parents | 74164ac3d01a |
children | 5ed0c78a6785 |
files | plugins/history/history.js plugins/history/history.md |
diffstat | 2 files changed, 53 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/history/history.js Thu May 19 20:56:22 2016 +0200 +++ b/plugins/history/history.js Thu May 19 21:17:50 2016 +0200 @@ -16,7 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* Modules */ +// Modules. var Directory = Irccd.Directory; var File = Irccd.File; var Logger = Irccd.Logger; @@ -24,7 +24,7 @@ var Server = Irccd.Server; var Util = Irccd.Util; -/* Plugin information */ +// Plugin information. info = { author: "David Demelier <markand@malikania.fr>", license: "ISC", @@ -32,7 +32,7 @@ version: "@IRCCD_VERSION@" }; -var formats = { +Plugin.format = { "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}", @@ -59,9 +59,8 @@ "server": server.toString(), "channel": channel }); - } else { + } else p = Plugin.cachePath + "db.json"; - } return p; } @@ -119,7 +118,16 @@ function loadFormats() { - 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") @@ -128,7 +136,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]; } } @@ -145,12 +153,12 @@ }; if (args.length !== 2 || args[0].length === 0 || args[1].length === 0) { - server.message(channel, Util.format(formats.usage, kw)); + server.message(channel, Util.format(Plugin.format.usage, kw)); return; } if (args[0] !== "seen" && args[0] !== "said") { - server.message(channel, Util.format(formats.usage, kw)); + server.message(channel, Util.format(Plugin.format.usage, kw)); return; } @@ -163,14 +171,14 @@ kw.target = args[1]; if (!info) { - server.message(channel, Util.format(formats.unknown, kw)); + server.message(channel, Util.format(Plugin.format.unknown, kw)); return; } kw.date = info.timestamp; kw.message = info.message ? info.message : ""; - server.message(channel, Util.format(formats[args[0] == "seen" ? "seen" : "said"], kw)); + server.message(channel, Util.format(Plugin.format[args[0] == "seen" ? "seen" : "said"], kw)); } catch (e) { server.message(channel, Util.format(kw)); }
--- a/plugins/history/history.md Thu May 19 20:56:22 2016 +0200 +++ b/plugins/history/history.md Thu May 19 21:17:50 2016 +0200 @@ -33,16 +33,35 @@ ## Configuration -You can use different formats. - The following options are available under the `[plugin.history]` section: - **file**: (string) path to the JSON file for saving information (Optional, default to cache directory). - - **format-error**: (string) format when an internal error occured, - - **format-seen**: (string) format for showing last seen, - - **format-said**: (string) format for showing the last message, - - **format-unknown**: (string) format when the user has never been seen, - - **format-usage**: (strnig) format to show the plugin usage. + +**Deprecated in irccd 2.1.0:** + + - **format-error**: Use `[format.history] error` instead, + - **format-seen**: Use `[format.history] seen` instead, + - **format-said**: Use `[format.history] said` instead, + - **format-unknown**: Use `[format.history] unknown` instead, + - **format-usage**: Use `[format.history] usage` instead. + +### Keywords supported + +The following keywords are supported: + +| Parameter | Keywords | +|-----------|-----------------| +| **file** | channel, server | + +## Formats + +The **history** plugin supports the following formats in `[format.history]` section: + + - **error**: (string) format when an internal error occured, + - **seen**: (string) format for showing last seen, + - **said**: (string) format for showing the last message, + - **unknown**: (string) format when the user has never been seen, + - **usage**: (strnig) format to show the plugin usage. <div class="panel panel-warning"> <div class="panel-heading">If you don't want to specify the **file** parameter, irccd will try to use the plugin cache @@ -58,13 +77,12 @@ The following keywords are supported: -| Format | Keywords | Notes | -|-------------------------|----------------------------------------------------|---------------------------------| -| (any) | channel, command, nickname, origin, plugin, server | | -| **file** | channel, server | does not support (any) | -| **format-seen** | target, (date) | target is the specified nick | -| **format-said** | message, target, (date) | | -| **format-unknown** | target | | +| Format | Keywords | Notes | +|-------------|----------------------------------------------------|------------------------------| +| (any) | channel, command, nickname, origin, plugin, server | | +| **seen** | target, (date) | target is the specified nick | +| **said** | message, target, (date) | | +| **unknown** | target | | Example: @@ -72,8 +90,8 @@ <div class="panel-heading">~/.config/irccd/irccd.conf</div> <div class="panel-body"> ````ini -[plugin.history] -format-seen = "#{target} has been seen on #{channel} the last time on: %d/%m/%Y %H:%M" +[format.history] +seen = "#{target} has been seen on #{channel} the last time on: %d/%m/%Y %H:%M" ```` </div> </div>