Multiple Links from the same trigger

Post Reply
Screwbucket
Posts: 2
Joined: Tue Dec 06, 2022 6:13 pm

Multiple Links from the same trigger

Post by Screwbucket »

Hey there! I'm trying to modify a trigger that someone else wrote. The current behavior is that when a URL appears, it fetches the image from the URL and links to it. The issue is that if someone posts two images from that website, only the first URL is given a link. How can I make it so that it applies to all URL's in the trigger? I'm sure the match all option will play a factor, but I'm not sure what to do beyond that.
Code: [show] | [select all] lua
 local saveFolder = "PATH GOES HERE"
 local link = matches[1]
 local explodedPath = Split( matches[2] .. "." .. matches[3], "/")
 local file = explodedPath[#explodedPath]
 local finalFile = explodedPath[#explodedPath-1] .. "." .. file
 
 if not io.exists(saveFolder .. finalFile) then
  downloadFile(saveFolder .. finalFile, link)
 end
 selectString(link,1)
 setUnderline(true) 
 setLink([[showImagePreview("]] .. finalFile .. [[")]],"Show Image Preview")
 resetFormat()

Post Reply