12
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local String = require "luan:String.luan"
|
|
4 local regex = String.regex or error()
|
|
5 local Io = require "luan:Io.luan"
|
|
6 local Http = require "luan:http/Http.luan"
|
|
7 local Shared = require "site:/lib/Shared.luan"
|
|
8 local js_error = Shared.js_error or error()
|
|
9 local Logging = require "luan:logging/Logging.luan"
|
|
10 local logger = Logging.logger "add_server.js"
|
|
11
|
|
12
|
|
13 local invite_regex = regex[[^https://discord.gg/(\w+)$]]
|
|
14
|
|
15 return function()
|
|
16 Io.stdout = Http.response.text_writer()
|
|
17 local parameters = Http.request.parameters
|
|
18 local id = parameters.id or error()
|
|
19 local name = parameters.name or error()
|
|
20 local icon = parameters.icon or error()
|
|
21 local invite = parameters.invite or error()
|
|
22 invite = invite_regex.match(invite)
|
|
23 logger.info("invite = "..invite)
|
|
24 if invite==nil then
|
|
25 js_error( "invite", [[Invalid Discord invite URL]] )
|
|
26 return
|
|
27 end
|
|
28 %>
|
|
29 location = '/servers.html';
|
|
30 <%
|
|
31 end
|