From 26e66598a259399bb36a329005a7951a03b4a7ba Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Mon, 8 Jun 2020 16:54:52 -0600 Subject: [PATCH] added the contrib package and discord package, resolves #1071 --- .../reference/flux/stdlib/contrib/_index.md | 16 ++++ .../flux/stdlib/contrib/discord/_index.md | 28 ++++++ .../flux/stdlib/contrib/discord/send.md | 86 +++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 content/v2.0/reference/flux/stdlib/contrib/_index.md create mode 100644 content/v2.0/reference/flux/stdlib/contrib/discord/_index.md create mode 100644 content/v2.0/reference/flux/stdlib/contrib/discord/send.md diff --git a/content/v2.0/reference/flux/stdlib/contrib/_index.md b/content/v2.0/reference/flux/stdlib/contrib/_index.md new file mode 100644 index 000000000..5355284b8 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/_index.md @@ -0,0 +1,16 @@ +--- +title: Flux user-contributed functions +list_title: User-contributed functions +description: > + User-contributed packages and functions are contributed and maintained by members of the InfluxDB and Flux communities. +menu: + v2_0_ref: + name: User-contributed + parent: Flux standard library +weight: 202 +v2.0/tags: [contributed, functions, package] +--- + +User-contributed packages and functions are contributed and maintained by members of the InfluxDB and Flux communities. + +{{< children >}} diff --git a/content/v2.0/reference/flux/stdlib/contrib/discord/_index.md b/content/v2.0/reference/flux/stdlib/contrib/discord/_index.md new file mode 100644 index 000000000..7bff095dd --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/discord/_index.md @@ -0,0 +1,28 @@ +--- +title: Flux Discord package +list_title: Discord package +description: > + The Flux Discord package provides functions for sending data to Discord. + Import the `contrib/chobbs/discord` package. +menu: + v2_0_ref: + name: Discord + parent: User-contributed +weight: 202 +v2.0/tags: [functions, discord, package] +--- + +The Flux Discord package provides functions for sending data to Discord. +Import the `contrib/chobbs/discord` package: + +```js +import "contrib/chobbs/discord" +``` + +{{< children type="functions" show="pages" >}} + +{{% note %}} +#### Package author and maintainer +**Github:** [@chobbs](https://github.com/chobbs) +**InfluxDB Slack:** [@craig](https://influxdata.com/slack) +{{% /note %}} diff --git a/content/v2.0/reference/flux/stdlib/contrib/discord/send.md b/content/v2.0/reference/flux/stdlib/contrib/discord/send.md new file mode 100644 index 000000000..62f6bdee8 --- /dev/null +++ b/content/v2.0/reference/flux/stdlib/contrib/discord/send.md @@ -0,0 +1,86 @@ +--- +title: discord.send() function +description: > + The `discord.send()` function sends a single message to a Discord channel using + a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3). +menu: + v2_0_ref: + name: discord.send + parent: Discord +weight: 202 +--- + +The `discord.send()` function sends a single message to a Discord channel using +a [Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks&?page=3). + +_**Function type:** Output_ + +```js +import "contrib/chobbs/discord" + +discord.send( + webhookToken: "mySuPerSecRetTokEn", + webhookID: "123456789", + username: "username", + content: "This is an example message", + avatar_url: "https://example.com/avatar_pic.jpg" +) +``` + +## Parameters + +### webhookToken +Discord [webhook token](https://discord.com/developers/docs/resources/webhook). + +_**Data type:** String_ + +### webhookID +Discord [webhook ID](https://discord.com/developers/docs/resources/webhook). + +_**Data type:** String_ + +### username +Override the Discord webhook's default username. + +_**Data type:** String_ + +### content +Message to send to Discord (2000 character limit). + +_**Data type:** String_ + +### avatar_url +Override the Discord webhook's default avatar. + +_**Data type:** String_ + +## Examples + +##### Send the last reported status to Discord +```js +import "contrib/chobbs/discord" +import "influxdata/influxdb/secrets" + +token = secrets.get(key: "DISCORD_TOKEN") + +lastReported = + from(bucket: "example-bucket") + |> range(start: -1m) + |> filter(fn: (r) => r._measurement == "statuses") + |> last() + |> findRecord(fn: (key) => true, idx: 0) + +discord.send( + webhookToken:token, + webhookID: "1234567890", + username: "chobbs", + content: "The current status is \"${lastReported.status}\".", + avatar_url: "https://staff-photos.net/pic.jpg" +) +``` + +{{% note %}} +#### Package author and maintainer +**Github:** [@chobbs](https://github.com/chobbs) +**InfluxDB Slack:** [@craig](https://influxdata.com/slack) +{{% /note %}}