Mercurial > irccd
diff plugins/history/history.js @ 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 | aa205621d7d6 |
children | 9672dc88a158 |
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)); }