changeset 146:175bc5d41cc4

Plugin roulette: use new format section, #410
author David Demelier <markand@malikania.fr>
date Thu, 19 May 2016 22:29:15 +0200
parents 410f71eb9237
children d2ed121a6a99
files plugins/roulette/roulette.js plugins/roulette/roulette.md
diffstat 2 files changed, 41 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/roulette/roulette.js	Thu May 19 22:21:54 2016 +0200
+++ b/plugins/roulette/roulette.js	Thu May 19 22:29:15 2016 +0200
@@ -16,12 +16,13 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+// Modules.
 var Logger = Irccd.Logger;
 var Plugin = Irccd.Plugin;
 var Server = Irccd.Server;
 var Util = Irccd.Util;
 
-/* Plugin information */
+// Plugin information.
 info = {
 	author: "David Demelier <markand@malikania.fr>",
 	license: "ISC",
@@ -29,6 +30,14 @@
 	version: "@IRCCD_VERSION@"
 };
 
+/**
+ * Formats for writing.
+ */
+Plugin.format = {
+	"lucky":	"#{nickname}, you're lucky this time",
+	"shot":		"HEADSHOT"
+};
+
 function Gun(server, channel)
 {
 	this.server = server;
@@ -43,14 +52,6 @@
 Gun.map = {};
 
 /**
- * Formats for writing.
- */
-Gun.formats = {
-	"lucky":	"#{nickname}, you're lucky this time",
-	"shot":		"HEADSHOT"
-};
-
-/**
  * Search for an existing game.
  *
  * @param server the server object
@@ -89,7 +90,16 @@
  */
 Gun.loadFormats = function ()
 {
-	for (var key in Gun.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")
@@ -98,7 +108,7 @@
 		if (Plugin.config[optname].length === 0)
 			Logger.warning("skipping empty '" + optname + "' format");
 		else
-			Gun.formats[key] = Plugin.config[optname];
+			Plugin.format[key] = Plugin.config[optname];
 	}
 }
 
@@ -131,10 +141,10 @@
 		game = Gun.create(server, channel);
 
 	if (game.shot()) {
-		server.kick(Util.splituser(origin), channel, Util.format(Gun.formats["shot"], kw));
+		server.kick(Util.splituser(origin), channel, Util.format(Plugin.format["shot"], kw));
 		Gun.remove(game);
 	} else {
 		kw.count = (6 - game.index).toString();
-		server.message(channel, Util.format(Gun.formats["lucky"], kw));
+		server.message(channel, Util.format(Plugin.format["lucky"], kw));
 	}
 }
--- a/plugins/roulette/roulette.md	Thu May 19 22:21:54 2016 +0200
+++ b/plugins/roulette/roulette.md	Thu May 19 22:29:15 2016 +0200
@@ -31,21 +31,28 @@
 
 ## Configuration
 
-The **roulette** plugin can be configured to use different formats.
-
 The following options are available under the `[plugin.roulette]` section:
 
-  - **format-lucky**: (string) the text to show on luck,
-  - **format-shot**: (string) the text to show on shot.
+**Deprecated in irccd 2.1.0:**
+
+  - **format-lucky**: Use `[format.roulette] lucky` instead,
+  - **format-shot**: Use `[format.roulette] shot` instead,
+
+## Formats
+
+The **roulette** plugin supports the following formats in `[format.roulette]` section:
+
+  - **lucky**: (string) the text to show on luck,
+  - **shot**: (string) the text to show on shot.
 
 ### Keywords supported
 
 The following keywords are supported:
 
-| Format           | Keywords                                           | Notes                             |
-|------------------|----------------------------------------------------|-----------------------------------|
-| (any)            | channel, command, nickname, origin, plugin, server | all formats                       |
-| **format-lucky** | count                                              | the number of cylinder count left |
+| Format    | Keywords                                           | Notes                             |
+|-----------|----------------------------------------------------|-----------------------------------|
+| (any)     | channel, command, nickname, origin, plugin, server | all formats                       |
+| **lucky** | count                                              | the number of cylinder count left |
 
 Example:
 
@@ -53,9 +60,9 @@
  <div class="panel-heading">~/.config/irccd/irccd.conf</div>
  <div class="panel-body">
 ````ini
-[plugin.roulette]
-format-lucky = "#{nickname} you're gonna get shot"
-format-shot = "BIM"
+[format.roulette]
+lucky = "#{nickname} you're gonna get shot"
+shot = "BIM"
 ````
  </div>
 </div>