examples/evil.lua
changeset 111 5bcdb71ef2f2
parent 99 ed4676536ed9
child 121 75a7d595817c
--- a/examples/evil.lua	Mon Apr 12 00:41:23 2010 +0300
+++ b/examples/evil.lua	Wed Apr 14 11:21:02 2010 +0300
@@ -86,8 +86,7 @@
 			evil_handler_registered = true
 		end
 	end
-main.hook ( 'hook-post-connect', evil_pc_handler )
-main.hook ( 'hook-pre-disconnect',
+local evil_pd_handler = 
 	function ( args )
 		if evil_handler_registered then
 			local connection = main.connection ()
@@ -98,7 +97,9 @@
 			end
 			evil_handler_registered = false
 		end
-	end )
+	end
+main.hook ( 'hook-post-connect',   evil_pc_handler )
+main.hook ( 'hook-pre-disconnect', evil_pd_handler )
 
 main.hook ( 'hook-lua-start',
 	function ( args )
@@ -108,6 +109,7 @@
 main.hook ( 'hook-lua-quit',
 	function ( args )
 		main.del_feature ( 'http://jabber.org/protocol/evil' )
+		evil_pd_handler ()
 	end )
 
 local char2xmpp = {