Browse Source

added send hook. added $o to sandbox.

Nathaniel van Diepen 11 years ago
parent
commit
a0944fb0d8
2 changed files with 12 additions and 6 deletions
  1. 3 0
      app/www/data/plugins/test/script.js
  2. 9 6
      app/www/js/omnomirc.js

+ 3 - 0
app/www/data/plugins/test/script.js

@@ -2,4 +2,7 @@ hook('message',function(msg,from,room){
 	if(msg =='funny'){
 	if(msg =='funny'){
 		$o.chat.send('Not funny',room);
 		$o.chat.send('Not funny',room);
 	}
 	}
+});
+hook('send',function(msg,room){
+	return msg.toLowerCase()!='the game';
 });
 });

+ 9 - 6
app/www/js/omnomirc.js

@@ -312,7 +312,8 @@
 		plugins = [],
 		plugins = [],
 		pluginSandbox = {
 		pluginSandbox = {
 			$: window.jQuery,
 			$: window.jQuery,
-			jQuery: window.jQuery
+			jQuery: window.jQuery,
+			$o: $o
 		},
 		},
 		currentPlugin = 0,
 		currentPlugin = 0,
 		Sandbox = function(sandbox){
 		Sandbox = function(sandbox){
@@ -915,11 +916,13 @@
 							msg = msg.substr(1);
 							msg = msg.substr(1);
 						}
 						}
 						event(msg,'send');
 						event(msg,'send');
-						emit('message',{
-							message: msg,
-							room: room,
-							from: properties.nick
-						});
+						if(runHook('send',[msg,room])){
+							emit('message',{
+								message: msg,
+								room: room,
+								from: properties.nick
+							});
+						}
 					}
 					}
 				}
 				}
 			},
 			},