jammsen / docker-palworld-dedicated-server

Docker container to easily provision and manage Palworld Dedicated Server
https://hub.docker.com/r/jammsen/palworld-dedicated-server
MIT License
911 stars 158 forks source link

[Feature-Request] Variable for "content" in webhooks #223

Closed Jadiction closed 7 months ago

Jadiction commented 7 months ago

Have you read the Important information text above

Describe the feature

My suggestion is to allow customization/removal of the "content": "Status update" in includes/webhook.sh through ENV variables. For Discord webhooks, the message would look better without the content message.

Current:

  cat <<EOF
{
  "content": "Status update",
  "embeds": [{
    "title": "$1",
    "description": "$2",
    "color": "$3"
  }]
}
EOF
}

Suggestion: Add an environment variable like "WEBHOOK_ALL_TITLE" (for example) to allow users to customize the message. This way I can set it to nothing and only have the embed. This also helps non-English users who would like to translate it to their server's native language.

generate_post_data() {
  cat <<EOF
{
  "content": WEBHOOK_ALL_TITLE,
  "embeds": [{
    "title": "$1",
    "description": "$2",
    "color": "$3"
  }]
}
EOF
}

Additional information

Final checks

jammsen commented 7 months ago

Hey @Jadiction - Should the line "content": WEBHOOK_ALL_TITLE, be removed if the ENV variable is set to empty/nothing?

jammsen commented 7 months ago

Also please use the Prefix of titles like i set it up for FR, that helps me to stay organized.

Jadiction commented 7 months ago

Hey @Jadiction - Should the line "content": WEBHOOK_ALL_TITLE, be removed if the ENV variable is set to empty/nothing?

Good question, certain webhooks may require the content to be specified (even if empty). Depending on how you'd like it, I can think of 2 solutions:

  1. If the ENV variable is specified, the line gets used (aka don't check if empty, only if set), otherwise exclude the line.
  2. To play it safe and default it to "Status update," check for the ENV variable to be "NULL" to exclude it if ENV var is set & not "null", include line else if the ENV variable is not empty, content = ENV var, else content = "Status update"

I understand this makes it a little specific and would need some extra explaining in the documentation, but I believe it adds customizability.

jammsen commented 7 months ago

WEBHOOK_ALL_TITLE will never be not set, because it goes in the Dockerfile for default-sets and Backwards-Compability. This makes things more complicated. But when i understand you correctly you would offer:

if "isset" WEBHOOK_ALL_TITLE -> Add line and value if "empty" WEBHOOK_ALL_TITLE -> Remove line

Right? I think talking in pseudo-code is more easy to explain than very comlicated text 🤣

jammsen commented 7 months ago

@Jadiction Ping

Jadiction commented 7 months ago

WEBHOOK_ALL_TITLE will never be not set, because it goes in the Dockerfile for default-sets and Backwards-Compability. This makes things more complicated. But when i understand you correctly you would offer:

Ah true, after thinking about it, the first solution wouldn't work, my bad. Was thinking differently.

if "isset" WEBHOOK_ALL_TITLE -> Add line and value if "empty" WEBHOOK_ALL_TITLE -> Remove line

Yeah, this would work well. Sorry for the delay.

jammsen commented 7 months ago

It doesnt really save space but it works: image

Pushing it to develop and to latest later.

jammsen commented 7 months ago

See https://discord.com/channels/532141442731212810/1209949579185881139/1211257198869749800

jammsen commented 7 months ago

@Jadiction Please go ahead and test it and give me feedback.

Jadiction commented 7 months ago

@Jadiction Please go ahead and test it and give me feedback.

Works good! Thank you!

To me, this looks better image rather than repeating the "Status update" when the information in the embed shows everything needed image

jammsen commented 7 months ago

@Jadiction all good, happy to help!

jammsen commented 7 months ago

If you like this project, please consider giving this repo and the Docker-Hub-Repo a Star.