Skip to content

Formatting

Mirror.bot offers comprehensive way to format messages using templates. To the programmatically inclined we use go/templates.

Text Template

To construct a textual message you can use any text combined with variables inside {{ }}, for example

This is a new article {{ .Title }} you can view it [here]({{.Link}})
Messages can be enhanced with markdown the same as any other Discord text message.

Embed Template

The embed template uses the same syntax as the text template to provide the values. It has a lot more fields you can edit like:

Edit embed in the web dashboard

For now it's only accessible from the Web Dashboard.
Here is a picture representation of what the fields correspond too:

Example embed in discord

RSS variables

For feed (RSS) and messages this is the all variables available:

  • Title: {{ .Title }}
  • Description: {{ .Description }}
  • Content: {{ .Content }}
  • Link: {{ .Link }}
  • Updated: {{ .Updated }}
  • Published: {{ .Published }}
  • GUID: {{ .GUID }}
  • Authors: {{ range .Authors }}{{ .Name }} ({{ .Email }}){{ end }}
  • Categories: {{ range .Categories }}{{ . }}, {{ end }}
  • Image URL: {{ with .Image }}{{ .URL }}{{ end }}
  • Image Title: {{ with .Image }}{{ .Title }}{{ end }}

Extensions are are a bit complex to access, for example this gets the youtube thumbnail URL:

{{- with .Extensions -}}{{- with .media -}}{{- with .group -}}{{- with index . 0}}{{- with .Children -}}{{- with .thumbnail -}}{{- with index . 0}}{{- with .Attrs -}}{{- if and .url -}}{{.url}}{{end}}{{end}}{{end}}{{end}}{{end}}{{end}}{{end}}{{end}}{{end}}
Generally to get an idea how to structure these templates is to view the structure on the filter web view and go from there (better solution in the works).

Twitch variables

Twitch message variables:

  • User Login {{ .UserLogin }}
  • User Name {{ .UserName }}
  • Game ID {{ .GameID }}
  • Game Name {{ .GameName }}
  • Title {{ .Title }}
  • Language {{ .Language }}
  • Thumbnail URL {{ .ThumbnailURL }}
  • Tags {{ .Tags }}
  • Mature Content {{ .IsMature }}

Twitch messages have no extensions.