Skip to content

Commit

Permalink
send content-type with webhooks, fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
emmachase committed May 9, 2020
1 parent 120b367 commit 3285876
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

### 2.0.4
### Fixed
- Fix Discord Webhooks

### 2.0.3
### Fixed
- Output Chests (`config.outChest`) work properly now
Expand Down
14 changes: 8 additions & 6 deletions src/logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ local slackName = config.slackName
local discordName = config.discordName
local externName

local webhookHeaders = {["Content-Type"] = "application/json", ["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"}

local function time()
return os.epoch("utc")
end
Expand Down Expand Up @@ -81,28 +83,28 @@ end

function logger.externInfo(text)
if slackURL then
http.post(slackURL, textutils.serializeJSON({username = externName, text = text}), {["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"})
http.post(slackURL, textutils.serializeJSON({username = externName, text = text}), webhookHeaders)
end

if discordURL then
http.post(discordURL, textutils.serializeJSON({username = externName, content = text}), {["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"})
http.post(discordURL, textutils.serializeJSON({username = externName, content = text}), webhookHeaders)
end
end

function logger.externMention(text)
if slackURL then
if slackName then
http.post(slackURL, textutils.serializeJSON({username = externName, text = "<@" .. slackName .. "> " .. text}), {["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"})
http.post(slackURL, textutils.serializeJSON({username = externName, text = "<@" .. slackName .. "> " .. text}), webhookHeaders)
else
http.post(slackURL, textutils.serializeJSON({username = externName, text = "<@" .. slackName .. "> " .. text}), {["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"})
http.post(slackURL, textutils.serializeJSON({username = externName, text = "<@" .. slackName .. "> " .. text}), webhookHeaders)
end
end

if discordURL then
if discordName then
http.post(discordURL, textutils.serializeJSON({username = externName, content = "<@" .. discordName .. "> " .. text}), {["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"})
http.post(discordURL, textutils.serializeJSON({username = externName, content = "<@" .. discordName .. "> " .. text}), webhookHeaders)
else
http.post(discordURL, textutils.serializeJSON({username = externName, content = text}), {["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"})
http.post(discordURL, textutils.serializeJSON({username = externName, content = text}), webhookHeaders)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

--#include "src/macros.lua"

local versionTag = "v2.0.3"
local versionTag = "v2.0.4"

local args = {...}
local layoutMode = args[1] == "--layout" or args[1] == "-l"
Expand Down

0 comments on commit 3285876

Please sign in to comment.