examples/urls.lua
changeset 8 fc9060b9b7cc
child 31 54957980a83a
equal deleted inserted replaced
7:eb6d89bf1fbf 8:fc9060b9b7cc
       
     1 -- SAVING URLS TO FILE
       
     2 
       
     3 url_file = main.config_file ( 'urls.log' )
       
     4 
       
     5 hooks_d['hook-message-in'].urls =
       
     6 	function ( args )
       
     7 		for url in args.message:gmatch ( "https?://[%w%p]+" ) do
       
     8 			fd = io.open ( url_file, "a" )
       
     9 			if fd then
       
    10 				fd:write ( url .. "\n" )
       
    11 				fd:close ()
       
    12 			else
       
    13 				print 'Cannot open urls log file'
       
    14 			end
       
    15 		end
       
    16 	end
       
    17 
       
    18 -- vim: se ts=4: --