Advertisement
9551

welcome message formatter

Aug 9th, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. local input = read()
  2. local rand = tostring(math.random(1, 10000000))
  3. local web, err = http.get(input)
  4. if err then
  5.     error(err, 0)
  6. end
  7. local file = fs.open(".temp_" .. rand, "w")
  8. file.write(web.readAll())
  9. file.close()
  10. local lines = {}
  11. for l in io.lines(".temp_" .. rand) do
  12.     lines[#lines + 1] = l
  13. end
  14. local nameplaces = {}
  15. for place, dat in pairs(lines) do
  16.     if dat:match("^ %?") then
  17.         nameplaces[#nameplaces + 1] = place
  18.     end
  19. end
  20. local names = {}
  21. for _, data in pairs(nameplaces) do
  22.     names[#names + 1] = lines[data - 2]
  23. end
  24. for place, info in ipairs(names) do
  25.     names[place] = "@" .. info
  26. end
  27. local basemsg = table.concat(names, " ")
  28. local final = "Welcome " .. basemsg
  29. fs.delete(".temp_" .. rand)
  30. local file = fs.open("OUTPUT_" .. rand .. ".msg", "w")
  31. file.write(final)
  32. file.close()
  33. shell.run("pastebin", "put", "OUTPUT_" .. rand .. ".msg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement