A dead simple discord poster. Created for Game Plus.
Discord has webhooks (Thats how this works). But you have to pass it JSON so it can be annoying to use with services like IFTTT.
This also allows you to do pre-processing to the input before its posted.
We can also convert Slack webhooks to Discord.
POST data to the endpoint and it will post it to the relevant discord room.
The API must be called with this format:
https://xxxxxx/post/{channel}/{key}
Discord Webhook URL:
https://discordapp.com/api/webhooks/{channel}/{key}
To use the Slack webhook to Discord conversion use this URL scheme:
https://xxxxxx/slack/{channel}/{key}
You can pass extra parameters to the API.
Key | Description |
---|---|
target | The user or group you want to mention. |
filter | Filter to apply. Separated by , |
Default Filters:
Filter | Description |
---|---|
html | Converts HTML to plain text. |
whitespace | Removes extra horizontal whitespace. |
You can pass in custom filters by pass it as the environment variable CUSTOM_FILTERS
.
Syntax: The syntax for filters is as follows.
{{<KEY>}}={{<FIND>}}={{<REPLACE>}}~{{<KEY>}}={{<FIND>}}={{<REPLACE>}}
Note: All text values must be wrapped in {{
}}
.
Key | Description |
---|---|
~ |
Separator between filters. |
{{<KEY>}} |
Filter name. |
{{<FIND>}} |
Find target. (Regex must start with \ ) |
{{<REPLACE>}} |
Replace target. |
Example for replacing drinks
with cocktails
.
{{more-cocktails}}={{drinks}}={{cocktails}}
This will post a message to a channel with a @everyone
and apply whitespace & cocktail filtering.
https://xxxxxx/post/{channel}/{key}?target=everyone&filter=more-cocktails,whitespace