Skip to content

Conversation

@DasMaffin
Copy link

@DasMaffin DasMaffin commented Apr 3, 2025

Added config.DiscordWebhookURL / Damagelog.DiscordWebhookURL
Refactored discord notification code to not need to use chttp anymore.

Refactored discord notification code to not need to use chttp anymore.
@DasMaffin DasMaffin changed the title Added config.DiscordWebhookURL / Damagelog/DiscordWebhookURL Refactored discord notification code to not need to use chttp anymore Apr 3, 2025
Copy link
Owner

@BadgerCode BadgerCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for doing this.

If we can default to using the existing convar for the webhook URL, it'll make updating easier for people.
But it's not the end of the world if we don't do it.

I can update the wiki.

-- 2 - create messages for every report
Damagelog.DiscordWebhookMode = 0
-- The URL of the webhook. You can create one in your Discord server settings.
Damagelog.DiscordWebhookURL = ""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah good spot.

It was originally left out of the lua config, to avoid people accidentally sharing their discord webhook URLs.
But now, we have JSON config files which live outside of the code for the addon.

So the discord webhook URL config can live with all of the other config 🎉

Damagelog.PrivateMessagePrefix = config.PrivateMessagePrefix

Damagelog.DiscordWebhookMode = config.DiscordWebhookMode
Damagelog.DiscordWebhookURL = config.DiscordWebhookURL
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to make the JSON config loader to pull any existing value from the console variable, for servers that already have it set up this way.

  1. Load the webhook URL from the JSON config file
  2. If the webhook URL is not set, try to load the webhook URL from the convar ttt_dmglogs_discordurl

if use_chttp then
HTTP = CHTTP
end

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this and it seems that discord have indeed unblocked requests from GMod servers!
(Or maybe the GMod server user agent changed).

Either way, yippee!

@DasMaffin
Copy link
Author

Okay, so, I did some research. I believe we could either a) scrap this, or b) make it work with these findings

The problem here is that discord allows the messages, if sent by a windows server. It responds with code 403 if you try running the same on a linux machine (also tested it in containers and it gives the same result). So now either we scrap this (a) or change it so it checks if it can send a message and if yes just use HTTP and if no require the 3rd party DLL, And I was already so happy to not have to use another DLL :(

@BadgerCode
Copy link
Owner

Ah maybe I tested it wrong the other day. I'm using a Linux server.
I'll try testing it again.

At the least, it would be nice to get the config changes into the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants