Skip to content

Conversation

@NoF0rte
Copy link

@NoF0rte NoF0rte commented Mar 19, 2022

The message format is now a golang text template with access to the Sprig template functions.

Using the default format {{.Data}} will have the same outcome as the previous functionality.

This is an example of a Discord configuration:

discord:
  - id: "interactsh"
    discord_format: |
      {{$data := fromJson .Data}}{{$raw := index $data "raw-request"}}{{$remote := index $data "remote-address"}}
      Remote IP: {{$remote}}
      
      {{$raw}}

@ehsandeep ehsandeep changed the base branch from master to dev March 20, 2022 08:05
@ehsandeep ehsandeep requested review from Mzack9999 and parrasajad and removed request for parrasajad March 20, 2022 08:11
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link

@fopinappb fopinappb left a comment

Choose a reason for hiding this comment

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

I think using go templates (and sprig) should be the default in every templated variable!

maybe for retro-compatibility it'd be nice to add some

if {{data}} in format {
deprecationWarning("update your config to use {{.Data}} instead of {{data}} as latter is deprecated")
msg = strings.replace(msg, "{{data}}","{{.Data}}")
}

@ehsandeep ehsandeep added the Status: Review Needed The issue has a PR attached to it which needs to be reviewed label May 18, 2022
@Mzack9999 Mzack9999 added the Status: On Hold Similar to blocked, but is assigned to someone label May 30, 2022
@Mzack9999
Copy link
Member

Closing as not planned (dot prefixed variable names are a breaking change) - CC @ehsandeep

@Mzack9999 Mzack9999 closed this Jul 29, 2022
@fopina
Copy link

fopina commented Jul 29, 2022

Closing as not planned (dot prefixed variable names are a breaking change) - CC @ehsandeep

@Mzack9999 if a clean proposal allowing retro compatibility, would it be ok?
Something like I mentioned previously

@Mzack9999
Copy link
Member

@fopina I'm reopening the PR for discussion

@ehsandeep Shall we add an automatic conversion layer? On a side I find the syntax {{variable}} cleaner than {{.VariableName}}

@fopina
Copy link

fopina commented Jul 29, 2022

While the syntax in the current "find and replace" might be cleaner (and more natural to non-Gophers), the real advantage is supporting templating: conditions, loops, and, in this PR, all the sprig functions

One useful function in this case (service message payloads) is escape markdown, as an example

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

Labels

Status: On Hold Similar to blocked, but is assigned to someone Status: Review Needed The issue has a PR attached to it which needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants