Don't allow loading the same plugin more than once

Tue, 22 Dec 2009 05:10:08 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 22 Dec 2009 05:10:08 +0000
changeset 3
d1a9fb6495c6
parent 2
6b31cc678fd7
child 4
1eaa469140e9

Don't allow loading the same plugin more than once

init.lua file | annotate | diff | comparison | revisions
--- a/init.lua	Tue Dec 22 05:06:29 2009 +0000
+++ b/init.lua	Tue Dec 22 05:10:08 2009 +0000
@@ -11,7 +11,7 @@
 	if not stream then
 		error("riddim.new(): Verse stream required as first parameter", 2);
 	end
-	return setmetatable({ stream = stream, config = config or {} }, riddim_mt);
+	return setmetatable({ stream = stream, config = config or {}, plugins = {} }, riddim_mt);
 end
 
 -- self.conn is ready for stanzas
@@ -75,8 +75,10 @@
 end
 
 function riddim_mt:add_plugin(name)
-	require("riddim.plugins."..name);
-	return riddim.plugins[name](self);
+	if not self.plugins[name] then
+		self.plugins[name] = require("riddim.plugins."..name);
+		return riddim.plugins[name](self);
+	end
 end
 	
 -- Built-in bot starter

mercurial