An easy to use relay for cftools webhook events piped to Discord when filter rules match.

CFTools Relay

Discord Tests

CFTools Relay is an easy-to-use, still in development, tool that allows you to subscribe to CFTools Cloud Webhook events and forward them to a different target. Right now, the only target that is supported is as Discord Webhook URL.

Why?

CFTools Relay is a tool that is mostly done to allow filtering for specific CFTools events. CFTools Cloud already provides a way to send Webhooks for specific events to Discord, however, apart from the event name, there is no additional filter criteria that can be applied.

If one, e.g., would like to get a notification in Discord only, if a player kills another player from more than 500 meters away, potentially with a specific weapon (like an IJ 70) only, this is currently not possible with CFTools Webhooks. CFTools Relay allows to define such filters, which are applied to the incoming Webhook events. Only if at least one filter, with all filter rules, match the event, it will be forwarded/relayed to Discord.

Should I use this tool?

If you do not need to filter Webhook events based on data that is within an event (rather than just the event type), then you SHOULD NOT use this tool. It is only increasing complexity in this case, and you can achieve the very same outcome with the CFTools Cloud builtin Webhook-to-Discord feature. Simply use that.

If you, however, need some more filter logic on top of your Webhook events to further reduce the amount of messages your channel is flooded with, this tool might be of help.

Installation

The installation is as simple as downloading the latest version of this tool, put it somewhere and start it, either by double-clicking on the exe file (for Windows OS) or running the tool in a terminal (for Linux and Windows OS).

Download the latest version

You can either visit the release page to download the latest released version (which might miss some features from the current development version).

Alternatively, you can visit the automated build page, select the most recent successful run (with a green checkmark) and download the artifact for your operating system from the Artifacts section.

Configuration

Upon the first start of the tool, it will automatically create a configuration file, named config.json in the same directory as the binary.

Check port of the tool and your firewall

This tool will start an internal webserver, which is used to handle webhook events sent from CFTools to it. The webserver, by default, uses port 8080 to listen on. You need to ensure that this port is available to the tool and not used by another program/process already (like another webserver). If you do not want to use port 8080 for this tool, you can change the port in the created configuration file.

Also, make sure that the port you configured (or the default one) is whitelisted in your firewall configuration. The CFTools Relay is using an unencrypted connection using http. If you want to use a TLS-encrypted connection for your webhook messages, you may want to setup a reverse proxy for this tool, which handles the TLS termination. A setup like that is out-of-scope of this README.

First time setup

When you setup this tool the first time, you need to do some basic steps in order to create and verify the webhook in the CFTools Cloud console:

  1. Start the tool (if you did not do that already) and ensure it is able to receive web requests (see Check port of the tool and your firewall)
  2. Go to the CFTools Cloud Dashboard and open the server where the webhook should be added to
  3. Navigate to the Manage -> Integrations page of that server
  4. Add a new Webhook with the New Webhook button
  5. Enter the Webhook URL:
    • It consists of the public IP address or domain of your server (e.g. http://123.123.123.123)
    • appended is the Port (by default 8080) separated by a colon (:8080)
    • at the end it needs to have a fixed path: /cftools-webhook
    • For the example values above, the full webhook URL looks like: http://123.123.123.123:8080/cftools-webhook
  6. Select CFTools CLoud (Hephaistos v1) as the Payload format
  7. Click Deploy
  8. Reload the page and make sure it shows a green shield (which means Verified and active) next to the newly created webhook
  9. Open the Webhook details and copy the value in the Secret field
  10. Open the config.json of CFTools Relay in your favourite text editor
  11. Paste the copied secret into the value of the secret field inside the config. It should then look like this (when your secret is abc123):
    • "secret": "abc123",
  12. Save the config.json file and restart the CFTools Relay tool
  13. Go back to the Webhook details page of CFTools Cloud and select every event you want the CFTools Relay to receive
  14. Hit Save

You're done with the configuration on the CFTools side. Given CFTools Relay does not know where to relay the webhook event messages to right now, you need to configure the Discord target:

  1. Go to the Discord channel of your choice where the Webhook messages should be relayed to
  2. Open the settings of this channel
  3. Navigate to the Integrations section of the settings
  4. Create a new webhook (or use an existing one, up to you)
  5. Copy the Webhook URL value
  6. Open the config.json of CFTools Relay in your favourite text editor 7Paste the copied URL into the value of the discord.webhook_url field inside the config. It should then look like this (when your URL is http://example.com):
"discord": {
  "webhook_url": "http://example.com"
}
  1. Save the config.json file and restart the CFTools Relay tool

That's it. The first time configuration is now done and CFTools Relay will now start to forward Webhook events from CFTools Cloud to your discord channel.

Filter configuration

The main use case of CFTools Relay is to be able to filter events that should be forwarded to Discord. By default, there are no filters set up, which makes CFTools Relay to relay all messages to Discord.

There are two main concepts to understand before using filters:

Filters: You can have 0-n filters configured in CFTools Relay. Filters are evaluated independently of each other. If at least one filter matches a specific webhook event received from CFTools Cloud, this event will be relayed to Discord. That means, filters are combined with an OR operator. The only required field for filters is the event name this filter should apply to.

Rules: Each filter can have 0-n rules that are evaluated to the webhook event. Only if all defined rules match the event, the filter evaluates to "match the event", which would make the event be relayed to Discord. Rules are therefore combined with an AND operator.

Rules allow you to define more in-depth filtering on Webhook events, as they allow you to compare specific fields to values you define. The available fields heavily depend on the Webhook event type (see the JSON files in the payloads/ folder of this project for some information).

A usual configuration with one example filter looks like:

{
  "port": 8080,
  "secret": "...",
  "discord": {
    "webhook_url": "..."
  },
  "filter": [
    {
      "event": "user.join",
      "rules": null
    },
    {
      "event": "user.leave",
      "rules": null
    }
  ]
}

This filter will make CFTools Relay to only relay events with the type user.join and user.leave.

Example 1: Relay kill event when distance is greater than 1000 meter

If you wish to get a kill notification in your Discord channel only, if the distance between the Victim and the Murderer is greater than 1000 meters, you can add the following filter:

{
  "event": "player.kill",
  "rules": [
    {
      "comparator": "gt",
      "field": "distance",
      "value": 1000
    }
  ]
}

Example 2: Relay kill event when distance is greater than 100 meter with an IJ-70

Based on the previous example, you can also combine multiple rules and make filters that, e.g., relay a message to Discord only, if the kill was made over 100 meters between the Victim and the Murderer, as well as if the murderer used an IJ-70:

{
  "event": "player.kill",
  "rules": [
    {
      "comparator": "gt",
      "field": "distance",
      "value": 100
    },
    {
      "comparator": "eq",
      "field": "weapon",
      "value": "IJ-70"
    }
  ]
}

Available Comparators

The following table lists the available Comparators for filter rules:

Comparator Explanation
eq Equals comparator, matches only, if the value of the configured field in the event is exactly the configured value. This comparator is case-sensitive.
gt Greater than comparator, matches only, if the value of the configured field in the event is a numeric value and is greater than the configured value. This comparator never matches when the value is not a numeric field.
lt Less than comparator, matches only, if the value of the configured field in the event is a numeric value and is les than the configured value. This comparator never matches when the value is not a numeric field.
contains Contains comparator, matches only, if the value of the configured field in the event is a contains the configured value. This is a wildcard matcher, which is equivalent to *value* is wildcards would exist.
startsWith Starts with comparator, same as contains with the only difference, that the field value needs to start with the configured value (value* instead of *value*).
endsWith Ends with comparator, same as contains with the only difference, that the field value needs to end with the configured value (*value instead of *value*).
Owner
Florian
"Don't fix it because you should, fix it because you might be the only one who can." (Source: https://tools.wmflabs.org/bash/quip/AU7VTyDP6snAnmqnK_pQ)
Florian
Comments
  • Feature request: New

    Feature request: New "oneOf"/"in" comparator

    One use case could be: Forward all kill events for a kill with one of these weapons: AKM, AK-74, M4A1, IJ70, where the distance is longer than 400m.

    Right now, one would need to create one filter per weapon and add the two conditions (one weapon and distance) into it. More useful would be to be able to specify the list of weapons with an "onOf" comparator, which will match when one of these values match the field.

  • Allow to configure color and text of discord message

    Allow to configure color and text of discord message

    Currently, there is a fixed message and color for the discord message. However, with the introduction of virtual fields, the meaning of a message can be different, even if an event is the same, based on the filter that matched.

    The message should therefore be somehow configurable. The color maybe as well, but that would be the 120% solution :D

  • Support

    Support "unsupported" events

    Currently, I need to add each of the possible webhook events manually. However, this is usually only needed to add convenience strings, as well as remove unrelated information from the event data. Would probably be easier to have some kind of "best effort" default renderer for "unknown" events, so that they at least show the data, which is there, even given it is not rendered nicely.

  • Sort Discord embed fields in a reproducible order

    Sort Discord embed fields in a reproducible order

    Currently, the name of a kill message e.g. is sometimes at the beginning, sometimes at the start or in between. It should at least be a fixed order all the time for the same message type.

  • Support filter based on

    Support filter based on "kills in the last hour"

    That could be especially interesting when a high kills per hour number can be an indicator for a cheater and one would like to get a notification when a specific threshold is reached.

    • [x] Persist events for cftools IDs
    • [x] Add filter rule field for event count
    • [x] Cleanup persisted events after a reasonable (configurable?) time/amount
An easy-to-use discord bot written in go

Discord Bot An easy-to-use discord bot template written in golang using discordgo. This template was written for learning golang. It will be updated a

Jan 23, 2022
An easy-to-use discord bot template written in golang using discordgo

Discord Bot An easy-to-use discord bot template written in golang using discordgo. This template was written for learning golang. It will be updated a

Oct 30, 2021
The serverless OTP telegram service use telegram as OTP service, and send OTP through webhook

Setup OTP First thing, you need prepare API(webhook) with POST method, the payload format as below { "first_name": "Nolan", "last_name": "Nguyen",

Jul 24, 2022
discord bot that plays music in a voice channel discord

Music discord bot by serje3 Description A bot written in the Golang language plays music on your server's voice channel on Discord. It can be built an

Nov 17, 2021
A simple Discord bot developed for the Bedrock Gophers discord server.

Bedrock Gopher A simple Discord bot developed for the Bedrock Gophers discord server. Click here to invite the bot to your guild. You will also need t

Mar 12, 2022
Discord-dl: a tool to archive discord channels

discord-dl discord-dl is a tool to archive discord channels. I think it's safe t

May 18, 2022
Discord-notif - Send notifications to discord in Your pipelines or scripts
Discord-notif - Send notifications to discord in Your pipelines or scripts

discord-notif Send notifications to discord in Your pipelines or scripts install

Dec 15, 2022
Discord-finder - The back-end for retrieving information about people on discord
Discord-finder - The back-end for retrieving information about people on discord

About This is the backend application for Discord Finder, it allows you to retrive information about people on discord just like the discord lookup we

Jan 4, 2022
Discord-bot - A Discord bot with golang

JS discord bots Install Clone repo git clone https://github.com/fu-js/discord-bo

Aug 2, 2022
Wipe-discord - TUI application to erase Discord messages
Wipe-discord - TUI application to erase Discord messages

wipe-discord Terminal user interface (TUI) application to delete Discord message

Aug 21, 2022
Fancy, fully-featured, easy to use Telegram CAPTCHA bot written in Go
Fancy, fully-featured, easy to use Telegram CAPTCHA bot written in Go

Go Telegram Captcha Bot Fancy, fully-featured, easy to use, scalable Telegram CAPTCHA bot written in Go based on tucnak's telebot this robot only has

Jul 18, 2022
Twitchbot - Go Twitch Bot Api wrapper, with an easy to use interface.

twitchbot Go Twitch Bot Api wrapper, with an easy to use interface. Example package main import ( "twitch/twitchbot" ) func main() { bot := twitch

Jan 8, 2022
A Discord bot for managing ephemeral roles based upon voice channel member presence.
A Discord bot for managing ephemeral roles based upon voice channel member presence.

ephemeral-roles A Discord bot for managing ephemeral roles based upon voice channel member presence. Quickstart Click on the Ephemeral Roles logo head

Dec 19, 2022
Bot used for https://discord.gg/rflutterdev

FlutterDoc A bot offering exactly what we need in The r/FlutterDev Discord Server that Dyno can't offer us. Quick search patterns that can be embedded

Dec 8, 2022
Harmony is a peaceful Go module for interacting with Discord's API

Harmony Harmony is a peaceful Go module for interacting with Discord's API. Although this package is usable, it still is under active development so p

Sep 18, 2022
discord exploit tools written in golang

The ultimate CLI tool for TiKV

Aug 19, 2021
An extension for discordgo to create a Discord bot quickly using the Builder pattern.

botbuilder An extension for discordgo to create a Discord bot quickly using the Builder pattern. Example usage: package main import ( "log" "os"

Oct 12, 2022
Discordo is a lightweight, secure, and feature-rich Discord terminal client.
Discordo is a lightweight, secure, and feature-rich Discord terminal client.

discordo ยท [WIP] Discordo is a lightweight, secure, and feature-rich Discord terminal client. It is highly configurable and has a minimalistic user in

Jan 5, 2023
Formats discord tokens to different formats.
Formats discord tokens to different formats.

token_formatter Formats discord tokens to different formats. Features Format your current tokens to a new format! Every tool uses a different format f

Nov 3, 2022