Categorygithub.com/infosecstreams/StreamStatus
modulepackage
0.0.0
Repository: https://github.com/infosecstreams/streamstatus.git
Documentation: pkg.go.dev

# README

StreamStatus

This program updates streamer's status on the hacklist by receiving Twitch EventSub webhook requests, editing the repo markdown, and committing the changes back to GitHub.

Example Debug Output

You need to subscribe to stream.{offline,online} events from the Twitch EventSub API. This program listens on http://0.0.0.0:SS_PORT/webhook/callbacks for webhook requests from twitch containing JSON EventSub data:

{
  "subscription": {
    "id": "607e9634-8600-450c-948e-8cc1380fa9fe",
    "status": "enabled",
    "type": "stream.offline",
    "version": "1",
    "condition": { "broadcaster_user_id": "555942272" },
    "transport": {
      "method": "webhook",
      "callback": "https://98cf813101b4.ngrok.io/webhook/callbacks"
    },
    "created_at": "2021-07-24T08:09:34.816454134Z",
    "cost": 1
  },
  "event": {
    "broadcaster_user_id": "555942272",
    "broadcaster_user_login": "goproslowyo",
    "broadcaster_user_name": "GoProSlowYo"
  }
}

The code is bad and I feel bad.

Build It

Directly with go:

go mod tidy
go build -mod vendor -ldflags="-s -w" -o StreamStatus ./...

Or, build a docker image:

docker build -t streamstatus:dev .

Use It

Run directly with ENV vars:

SS_PORT=3000 SS_SECRETKEY=secret SS_TOKEN=token SS_USERNAME=username ./StreamStatus

Or, export required ENV vars:

# Port to listen on
export SS_PORT=3000
# Secret key to HMAC EventSub message
export SS_SECRETKEY=secret
# GitHub personal access token
export SS_TOKEN=token
# GitHub username
export SS_USERNAME=username

# Run:
./StreamStatus

Or, if you built the docker image:

docker run --rm -it -e SS_PORT=9001 -e SS_SECRETKEY=secret -e SS_TOKEN=token -e SS_USERNAME=username streamstatus:dev

# Structs

NoChangeNeededError is a struct for a custom error handler when no changes are needed to the git repository.
StreamersRepo struct represents fields to hold various data while updating status.