Pārlūkot izejas kodu

added send hook. added $o to sandbox.

Nathaniel van Diepen 10 gadi atpakaļ
vecāks
revīzija
a0944fb0d8
2 mainītis faili ar 12 papildinājumiem un 6 dzēšanām
  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'){
 		$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 = [],
 		pluginSandbox = {
 			$: window.jQuery,
-			jQuery: window.jQuery
+			jQuery: window.jQuery,
+			$o: $o
 		},
 		currentPlugin = 0,
 		Sandbox = function(sandbox){
@@ -915,11 +916,13 @@
 							msg = msg.substr(1);
 						}
 						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
+							});
+						}
 					}
 				}
 			},