Skip to content

Commit a042eea

Browse files
committed
refactor: hexagonal architecture
1 parent 0aa12f4 commit a042eea

29 files changed

+912
-1092
lines changed

.github/workflows/build-test.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build & test
1+
name: Build
22
on:
33
push:
44
branches:
@@ -17,13 +17,7 @@ jobs:
1717
uses: actions/setup-go@v3
1818
with:
1919
go-version: '>=1.20.0'
20-
- name: Create config.yml from secrets
21-
run: echo -n "${{ secrets.CONFIG_YML }}" | base64 --decode > config.yml
22-
- name: Create streams.yml from secrets
23-
run: echo -n "${{ secrets.STREAMS_YML }}" | base64 --decode > streams.yml
2420
- name: ls
2521
run: ls -la
2622
- name: Build
2723
run: go build -v ./...
28-
- name: Test with the Go CLI
29-
run: go test -v ./...

.github/workflows/goreleaser.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
with:
1919
go-version: '>=1.20.0'
2020
- name: Run GoReleaser
21-
uses: goreleaser/goreleaser-action@v4
21+
uses: goreleaser/goreleaser-action@v6
2222
with:
2323
distribution: goreleaser
24-
version: latest
24+
version: '~> v2'
2525
args: release --clean
2626
env:
2727
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ dist/
1919
go.work
2020

2121
# Non-sample configs
22-
config.yml
23-
streams.yml
22+
config.yml

.goreleaser.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ before:
55
hooks:
66
- go mod tidy
77
builds:
8-
- main: ./cmd/streamobserver
8+
- main: .
99
env:
1010
- CGO_ENABLED=0
1111
goos:
@@ -15,7 +15,6 @@ builds:
1515
archives:
1616
- files:
1717
- config.sample.yml
18-
- streams.sample.yml
1918
format_overrides:
2019
- goos: windows
2120
format: zip

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,5 @@ Go service to poll Twitch and Restreamer streams and notify Telegram chats and g
88

99
- Get a Telegram bot token from [here](https://t.me/BotFather)
1010
- Get a twitch client ID and secret by registering an application [here](https://dev.twitch.tv/console/apps)
11-
- Rename `config.sample.yml` to `config.yml` and enter your credentials
12-
- Rename `streams.sample.yml` to `streams.yml` and enter chats to notify and streams to observe
13-
- Either run via executable or `go run .\cmd\streamobserver\main.go` (pass `-debug` to enable lowest log level)
14-
11+
- Rename `config.sample.yml` to `config.yml` and enter your credentials and streams to observe
12+
- Either run via executable or `go run .`

cmd/streamobserver/main.go

-58
This file was deleted.

config.sample.yml

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1+
general:
2+
polling_interval: "180s"
3+
request_timeout: "20s"
4+
debug: false
5+
16
telegram:
2-
apikey: "Telegram-Bot-API-Key"
7+
apikey: "telegram-bot-key"
8+
39
twitch:
4-
client-id: "Twitch-Client-ID"
5-
client-secret: "Twitch-Client-Secret"
6-
general:
7-
# polling interval to check streams, keep in mind twitch api rate limits
8-
polling-interval: 180
9-
# chat/group/channel to use for go tests
10-
test-chatid: -1004242424242
11-
# enable json formatted logging
12-
json-logging: false
10+
client_id: "client-id"
11+
client_secret: "client-secret"
12+
13+
chats:
14+
# List of chat IDs to notify (private / group)
15+
- chatid: 42424242
16+
streams:
17+
twitch:
18+
# List of Twitch usernames to observe
19+
- username: "dashducks"
20+
restreamer:
21+
# List of restreamer streams to observe
22+
- baseurl: "https://server.restreamer.tld"
23+
# Channel ID
24+
id: "124278c-5a03-45ca-8302-c322f1127232"
25+
# Optional, for a custom page embedding the restreamer stream
26+
customurl: "https://stream.wrapper.tld"

go.mod

+21-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,27 @@ require (
1010
)
1111

1212
require (
13-
github.com/davecgh/go-spew v1.1.1 // indirect
13+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
14+
github.com/fsnotify/fsnotify v1.7.0 // indirect
15+
github.com/hashicorp/hcl v1.0.0 // indirect
16+
github.com/magiconair/properties v1.8.7 // indirect
1417
github.com/mattn/go-colorable v0.1.13 // indirect
1518
github.com/mattn/go-isatty v0.0.19 // indirect
16-
github.com/pmezard/go-difflib v1.0.0 // indirect
17-
golang.org/x/sys v0.12.0 // indirect
19+
github.com/mitchellh/mapstructure v1.5.0 // indirect
20+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
21+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
22+
github.com/sagikazarmark/locafero v0.4.0 // indirect
23+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
24+
github.com/sourcegraph/conc v0.3.0 // indirect
25+
github.com/spf13/afero v1.11.0 // indirect
26+
github.com/spf13/cast v1.6.0 // indirect
27+
github.com/spf13/pflag v1.0.5 // indirect
28+
github.com/spf13/viper v1.19.0 // indirect
29+
github.com/subosito/gotenv v1.6.0 // indirect
30+
go.uber.org/atomic v1.9.0 // indirect
31+
go.uber.org/multierr v1.9.0 // indirect
32+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
33+
golang.org/x/sys v0.18.0 // indirect
34+
golang.org/x/text v0.14.0 // indirect
35+
gopkg.in/ini.v1 v1.67.0 // indirect
1836
)

go.sum

+50
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,77 @@
11
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
23
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
34
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
7+
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
48
github.com/go-telegram/bot v1.9.1 h1:4vkNV6vDmEPZaYP7sZYaagOaJyV4GerfOPkjg/Ki5ic=
59
github.com/go-telegram/bot v1.9.1/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM=
610
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
11+
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
12+
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
13+
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
14+
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
715
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
816
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
917
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
1018
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
1119
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
20+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
21+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
22+
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
23+
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
1224
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
1325
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1426
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
27+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1528
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
1629
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
1730
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
31+
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
32+
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
33+
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
34+
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
35+
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
36+
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
37+
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
38+
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
39+
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
40+
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
41+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
42+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
43+
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
44+
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
45+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
46+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
47+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
48+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
49+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
50+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
51+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
52+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
1853
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
1954
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
55+
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
56+
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
57+
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
58+
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
59+
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
60+
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
61+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
62+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
2063
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2164
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2265
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
2366
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
67+
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
68+
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
69+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
70+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
2471
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2572
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
73+
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
74+
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
75+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2676
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2777
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)