examples/urls.lua
changeset 33 db5396037b43
parent 31 54957980a83a
child 58 aa3376776cf2
equal deleted inserted replaced
32:524fde5be49a 33:db5396037b43
     1 -- SAVING URLS TO FILE
     1 -- SAVING URLS TO FILE
     2 
       
     3 url_file = main.option ( 'lua_url_file' )
       
     4 
     2 
     5 hooks_d['hook-message-in'].urls =
     3 hooks_d['hook-message-in'].urls =
     6 	function ( args )
     4 	function ( args )
     7 		for url in args.message:gmatch ( "https?://[%w%p]+" ) do
     5 		for url in args.message:gmatch ( "https?://[%w%p]+" ) do
     8 			fd = io.open ( url_file, "a" )
     6 			fd = io.open ( main.fileoption 'lua_url_file', "a" )
     9 			if fd then
     7 			if fd then
    10 				fd:write ( url .. "\n" )
     8 				fd:write ( url .. "\n" )
    11 				fd:close ()
     9 				fd:close ()
    12 			else
    10 			else
    13 				print 'Cannot open urls log file'
    11 				print 'Cannot open urls log file'