summaryrefslogtreecommitdiff
path: root/discord.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-09-03 12:52:17 +0100
committerubq323 <ubq323@ubq323.website>2024-09-03 12:52:17 +0100
commitb3de433cfd4e39c8fe6d776e258db3b44a3ddd39 (patch)
tree1467b88252052836f6344793eee2fe51b7dc5947 /discord.lua
parent643e4202f4c5a5ee7a87779ffb69928e685db451 (diff)
more thing
Diffstat (limited to 'discord.lua')
-rw-r--r--discord.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/discord.lua b/discord.lua
new file mode 100644
index 0000000..27e0644
--- /dev/null
+++ b/discord.lua
@@ -0,0 +1,24 @@
+local http_request = require'http.request'
+local dkjson = require'dkjson'
+local url = 'https://discord.com/api/v8/webhooks/1277689699254800436/gzYU3voeunQsEdC797-hgXdTIbJDk09IVuj6l1t2alqbX9xS0d_St7bDWRkagUuQ3sat'
+
+local function exec_webhook(url, payload, debug)
+ local req = http_request.new_from_uri(url)
+ req.headers:upsert('content-type','application/json')
+ req.headers:upsert(':method','POST')
+ req:set_body(dkjson.encode(payload))
+ local resp_head, resp_body = assert(req:go())
+ local status = resp_head:get':status'
+ if debug then
+ resp_head:dump()
+ print()
+ print(resp_body:get_body_as_string())
+ end
+ assert(status:sub(1,1) == '2', 'status was '..status..' not 2xx')
+end
+
+return { grom = function(from,body) print(body) exec_webhook(url, {
+ content=body,
+ username=from,
+ }, true) end }
+