examples/evil.lua
changeset 64 bf7521ed96eb
parent 63 423555c07763
child 66 542f61e113cb
equal deleted inserted replaced
63:423555c07763 64:bf7521ed96eb
     5 --       also we cannot detect stream-level evil :(
     5 --       also we cannot detect stream-level evil :(
     6 
     6 
     7 -- library
     7 -- library
     8 
     8 
     9 require 'lm'
     9 require 'lm'
    10 require 'iq'
    10 local iq = require 'iq'
    11 
    11 
    12 -- public
    12 -- public
    13 
    13 
    14 evil = {
    14 evil = {
    15 	handler =
    15 	handler =
    53 evil.handler =
    53 evil.handler =
    54 	function ( mess )
    54 	function ( mess )
    55 		local evillevel = tonumber(main.option ( 'lua_evil_sensibility' ))
    55 		local evillevel = tonumber(main.option ( 'lua_evil_sensibility' ))
    56 		local mtype, smtype = mess:type ()
    56 		local mtype, smtype = mess:type ()
    57 		if evillevel > 1 then
    57 		if evillevel > 1 then
    58 			main.print_info ( mess:attribute ( 'from' ), 'Evil stanza of type "' .. mtype .. ' ' .. smtype .. '" detected!' )
    58 			main.print_info ( mess:attribute ( 'from' ), 'Evil stanza of type ' .. mtype .. '.' .. smtype .. ' detected!' )
    59 		elseif evillevel > 0 then
    59 		elseif evillevel > 0 then
    60 			print ( 'Tainted by evil stanza of type "' .. mtype .. ' ' .. smtype .. '" from ' .. ( mess:attribute ( 'from' ) or '... unknown in black' ) )
    60 			print ( 'Tainted by evil stanza of type ' .. mtype .. '.' .. smtype .. ' from ' .. ( mess:attribute ( 'from' ) or '... unknown in black' ) )
    61 		end
    61 		end
    62 		return main.yesno ( main.option ( 'lua_filter_evil' ) )
    62 		return main.yesno ( main.option ( 'lua_filter_evil' ) )
    63 	end
    63 	end
    64 
    64 
    65 local stat2xmpp = {
    65 local stat2xmpp = {