-- linkbot: fetches page titles for URLs posted in chat function on_message(nick, channel, text) for url in text:gmatch("https?://[%w%.%-_~:/?#%[%]@!$&'%(%)%*%+,;%%=]+") do local ok, body = pcall(http.get, url) if ok and body then local title = body:match("]*>([^<]+)") if title then title = title:gsub("%s+", " "):gsub("^%s+", ""):gsub("%s+$", "") if #title > 0 and #title < 200 then irc.send(channel, "^ " .. title) end end end end end