summaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
Diffstat (limited to 'discord')
-rw-r--r--discord/pylon.lua4
-rw-r--r--discord/the.lua24
2 files changed, 2 insertions, 26 deletions
diff --git a/discord/pylon.lua b/discord/pylon.lua
index fa2638d..1eb0a5a 100644
--- a/discord/pylon.lua
+++ b/discord/pylon.lua
@@ -8,7 +8,6 @@ local BasePylon = require 'pylon'
local Channel = require 'channel'
local consts = require 'discord.consts'
local opcodes = consts.opcodes
-local exec_webhook = require'discord.the'
local API_BASE = "https://discord.com/api/v10/"
@@ -127,7 +126,8 @@ end
function Discord.sending(self)
for dest_channel, message in self.inbox:iter() do
self.log:proto('>',dest_channel,message.sender,message.body)
- exec_webhook(self.channel_to_webhook[dest_channel.descriptor].url, {
+ local wh = self.channel_to_webhook[dest_channel.descriptor]
+ self._req('webhooks/'..wh.id..'/'..wh.token, {
username = message.sender,
content = message.body,
})
diff --git a/discord/the.lua b/discord/the.lua
deleted file mode 100644
index d3aaf58..0000000
--- a/discord/the.lua
+++ /dev/null
@@ -1,24 +0,0 @@
-local http_request = require'http.request'
-local dkjson = require'dkjson'
-
-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 exec_webhook
--- return { grom = function(from,body) print(body) exec_webhook(url, {
--- content=body,
--- username=from,
--- }, true) end }
-