Skip to content

Commit 4e579e8

Browse files
committed
Merge branch 'develop'
2 parents 999d0ab + 1dc8162 commit 4e579e8

20 files changed

+318
-209
lines changed

.github/workflows/deploy.yml

+5-20
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
-
1616
name: Docker meta
1717
id: meta
18-
uses: docker/metadata-action@v4
18+
uses: docker/metadata-action@v5
1919
with:
2020
images: ghcr.io/${{ github.repository_owner }}/putcallback
2121
flavor: |
@@ -26,38 +26,23 @@ jobs:
2626
type=semver,pattern={{raw}},priority=1100
2727
-
2828
name: Set up QEMU
29-
uses: docker/setup-qemu-action@v2
29+
uses: docker/setup-qemu-action@v3
3030
-
3131
name: Set up Docker Buildx
32-
uses: docker/setup-buildx-action@v2
32+
uses: docker/setup-buildx-action@v3
3333
-
3434
name: Login to GitHub Container Registry
35-
uses: docker/login-action@v2
35+
uses: docker/login-action@v3
3636
with:
3737
registry: ghcr.io
3838
username: ${{ github.repository_owner }}
3939
password: ${{ secrets.GITHUB_TOKEN }}
4040
-
4141
name: Build and push
42-
uses: docker/build-push-action@v3
42+
uses: docker/build-push-action@v6
4343
with:
4444
push: true
4545
tags: ${{ steps.meta.outputs.tags }}
4646
labels: ${{ steps.meta.outputs.labels }}
4747
cache-from: type=gha
4848
cache-to: type=gha,mode=max
49-
50-
dokku:
51-
name: Deploy to dokku host
52-
needs: docker
53-
runs-on: ubuntu-latest
54-
steps:
55-
-
56-
name: Build app
57-
uses: appleboy/[email protected]
58-
with:
59-
host: ${{ secrets.SSH_HOST }}
60-
username: dokku
61-
key: ${{ secrets.SSH_PRIVATE_KEY }}
62-
script: |
63-
git:from-image ${{ secrets.DOKKU_APP }} ${{ fromJson(needs.docker.outputs.meta).tags[0] }}

.github/workflows/goreleaser.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ jobs:
1414
steps:
1515
-
1616
name: Checkout
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
2020
-
2121
name: Set up Go
22-
uses: actions/setup-go@v3
22+
uses: actions/setup-go@v5
2323
with:
24-
go-version: 1.19
24+
go-version: 1.21
2525
-
2626
name: Run GoReleaser
27-
uses: goreleaser/goreleaser-action@v3
27+
uses: goreleaser/goreleaser-action@v6
2828
with:
2929
distribution: goreleaser
30-
version: latest
31-
args: release --rm-dist
30+
version: '~> v1'
31+
args: release --clean
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ builds:
2222

2323
# Archive
2424
archives:
25-
-
26-
name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
27-
format: "binary"
25+
- format: tar.gz
26+
name_template: >-
27+
{{ .ProjectName }}_
28+
{{- title .Os }}_
29+
{{- if eq .Arch "amd64" }}x86_64
30+
{{- else if eq .Arch "386" }}i386
31+
{{- else }}{{ .Arch }}{{ end }}
32+
{{- if .Arm }}v{{ .Arm }}{{ end }}
33+
format_overrides:
34+
- goos: windows
35+
format: zip
2836

2937
# Release
3038
release:
@@ -41,8 +49,10 @@ snapshot:
4149

4250
# Changelog
4351
changelog:
52+
sort: asc
4453
filters:
4554
exclude:
4655
- "^docs"
4756
- "^test"
4857
- "^Merge branch"
58+
- "^Merge pull request"

.pre-commit-config.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/dnephin/pre-commit-golang
9+
rev: v0.5.1
10+
hooks:
11+
- id: go-fmt
12+
- id: go-mod-tidy

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM rclone/rclone:1.60.0 AS rclone
1+
FROM rclone/rclone:1.67.0 AS rclone
22

3-
FROM golang:1.19 AS builder
3+
FROM golang:1.21 AS builder
44

55
ENV CGO_ENABLED=0
66

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# putcallback
22

33
`putcallback` is a program which handles callback from [Put.io](https://put.io/).
4-
It will move files from Put.io to any other storage supported by [rclone](https://rclone.org/).
4+
It will move files from Put.io to any other storage supported by [rclone](https://rclone.org/).
55

66
## Prerequisites
77

@@ -23,6 +23,7 @@ env CGO_ENABLED=0 go install -trimpath -ldflags="-s -w" github.com/RoyXiang/putc
2323
* `REMOTE_SRC` and `REMOTE_DEST` (default: `src:` and `dest:`)
2424
* If something like `rclone move putio: drive:Downloads/` is wanted,
2525
set `REMOTE_SRC` to `putio:` and `REMOTE_DEST` to `drive:Downloads/`
26+
* `MAX_TRANSFERS` (default: the maximum number of simultaneous tasks allowed by your Put.io subscription)
2627
* `DELAY_BEFORE_TRANSFER` (default: `0s`)
2728
* Delay before moving files to the destination so that you can manipulate files on Put.io first
2829
* `EXCLUDE_FILETYPES` (e.g. `exe,log`)

go.mod

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
module github.com/RoyXiang/putcallback
22

3-
go 1.19
3+
go 1.21
44

55
require (
66
github.com/chonla/roman-number-go v0.0.0-20181101035413-6768129de021
77
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
8-
github.com/gregdel/pushover v1.1.0
9-
github.com/putdotio/go-putio v1.6.0
10-
github.com/rclone/rclone v1.60.0
11-
github.com/samber/lo v1.33.0
12-
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c
8+
github.com/gregdel/pushover v1.3.1
9+
github.com/putdotio/go-putio v1.7.1
10+
github.com/rclone/rclone v1.67.0
11+
github.com/samber/lo v1.47.0
12+
golang.org/x/oauth2 v0.22.0
13+
golang.org/x/sync v0.7.0
1314
)
1415

1516
require (
16-
github.com/golang/protobuf v1.5.2 // indirect
17+
github.com/google/go-cmp v0.6.0 // indirect
1718
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 // indirect
18-
github.com/sirupsen/logrus v1.9.0 // indirect
19-
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
20-
golang.org/x/net v0.23.0 // indirect
21-
golang.org/x/sys v0.18.0 // indirect
22-
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
23-
google.golang.org/appengine v1.6.7 // indirect
24-
google.golang.org/protobuf v1.33.0 // indirect
19+
github.com/sirupsen/logrus v1.9.3 // indirect
20+
golang.org/x/sys v0.21.0 // indirect
21+
golang.org/x/text v0.16.0 // indirect
22+
golang.org/x/time v0.5.0 // indirect
2523
)

go.sum

+57-36
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,87 @@
1-
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
1+
cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
22
github.com/chonla/roman-number-go v0.0.0-20181101035413-6768129de021 h1:F7ux9YUTBF8wykFrRhNJIuLyAkJhD6hs98M/lJM0ZW4=
33
github.com/chonla/roman-number-go v0.0.0-20181101035413-6768129de021/go.mod h1:mgLs523CF5p4A7oIy2Es5ZxuKnG3xhT3Ff0L7J/2J1c=
44
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5-
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
65
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
7+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
78
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
89
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
9-
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
1010
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
1111
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
12-
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
1312
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
1413
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
15-
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
16-
github.com/gregdel/pushover v1.1.0 h1:dwHyvrcpZCOS9V1fAnKPaGRRI5OC55cVaKhMybqNsKQ=
17-
github.com/gregdel/pushover v1.1.0/go.mod h1:EcaO66Nn1StkpEm1iKtBTV3d2A16SoMsVER1PthX7to=
14+
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
15+
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
16+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
17+
github.com/gregdel/pushover v1.3.1 h1:4bMLITOZ15+Zpi6qqoGqOPuVHCwSUvMCgVnN5Xhilfo=
18+
github.com/gregdel/pushover v1.3.1/go.mod h1:EcaO66Nn1StkpEm1iKtBTV3d2A16SoMsVER1PthX7to=
1819
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004 h1:G+9t9cEtnC9jFiTxyptEKuNIAbiN5ZCQzX2a74lj3xg=
1920
github.com/jzelinskie/whirlpool v0.0.0-20201016144138-0675e54bb004/go.mod h1:KmHnJWQrgEvbuy0vcvj00gtMqbvNn1L+3YUZLK/B92c=
20-
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2121
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
22-
github.com/putdotio/go-putio v1.6.0 h1:O8VRIU48ULeEb+xb837SkDXQLifFkIRYAbayfbTGcV8=
23-
github.com/putdotio/go-putio v1.6.0/go.mod h1:uMqhBEWCsZkR8an5uhK1z9TRuJFaNlJlrsqYiuj2NYY=
24-
github.com/rclone/rclone v1.60.0 h1:TMm1Nln2f5BDkQ0HsGmeGsNRG6I188NmZpvBTgYRSu0=
25-
github.com/rclone/rclone v1.60.0/go.mod h1:3nqSdPt1XZtgJhgKqhmnSzoA/ZjIy1WdInsa9VMM/d4=
26-
github.com/samber/lo v1.33.0 h1:2aKucr+rQV6gHpY3bpeZu69uYoQOzVhGT3J22Op6Cjk=
27-
github.com/samber/lo v1.33.0/go.mod h1:HLeWcJRRyLKp3+/XBJvOrerCQn9mhdKMHyd7IRlgeQ8=
28-
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
29-
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
22+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
23+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
24+
github.com/putdotio/go-putio v1.7.1 h1:316PpOMO2a7H73foRxlpHmekeLso07et26Z00YlwQ2A=
25+
github.com/putdotio/go-putio v1.7.1/go.mod h1:QhjpLhn3La/ea4FeJlp1qsiaFZDC0EIO8VUe8VEKMV0=
26+
github.com/rclone/rclone v1.67.0 h1:yLRNgHEG2vQ60HCuzFqd0hYwKCRuWuvPUhvhMJ2jI5E=
27+
github.com/rclone/rclone v1.67.0/go.mod h1:Cb3Ar47M/SvwfhAjZTbVXdtrP/JLtPFCq2tkdtBVC6w=
28+
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
29+
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
30+
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
31+
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
3032
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
33+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
3134
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
3235
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
33-
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
34-
github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M=
36+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
37+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
38+
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
3539
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
36-
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
37-
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
38-
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
39-
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
40+
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
41+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
4042
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
41-
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
42-
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
43-
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
44-
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c h1:q3gFqPqH7NVofKo3c3yETAP//pPI+G5mvB7qqj1Y5kY=
45-
golang.org/x/oauth2 v0.0.0-20220722155238-128564f6959c/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
46-
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
43+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
44+
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
45+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
46+
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
47+
golang.org/x/oauth2 v0.2.0/go.mod h1:Cwn6afJ8jrQwYMxQDTpISoXmXW9I6qF6vDeuuoX3Ibs=
48+
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
49+
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
50+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
51+
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
52+
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
53+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
4754
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
55+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
56+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
57+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4858
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
49-
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
50-
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
59+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
60+
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
61+
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
62+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
63+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
64+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
65+
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
5166
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
5267
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
53-
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 h1:ftMN5LMiBFjbzleLqtoBZk7KdJwhuybIU+FckUHgoyQ=
54-
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
68+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
69+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
70+
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
71+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
72+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
73+
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
74+
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
5575
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
76+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
77+
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
78+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
5679
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
57-
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
58-
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
5980
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
6081
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
6182
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
62-
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
63-
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
83+
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
6484
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
6585
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6686
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
87+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

notification/main.go

+8-36
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,29 @@ package notification
33
import (
44
"log"
55
"os"
6-
"strconv"
7-
"time"
8-
9-
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
10-
"github.com/gregdel/pushover"
116
)
127

13-
var (
14-
pushoverApp *pushover.Pushover
15-
recipient *pushover.Recipient
16-
17-
tgBotApi *tgbotapi.BotAPI
18-
tgChatId int64
19-
)
8+
var notifiers []notifier
209

2110
func init() {
2211
appToken := os.Getenv("PUSHOVER_APP_TOKEN")
2312
userToken := os.Getenv("PUSHOVER_USER_TOKEN")
24-
if appToken != "" && userToken != "" {
25-
pushoverApp = pushover.New(appToken)
26-
recipient = pushover.NewRecipient(userToken)
13+
if n, err := newPushoverNotifier(appToken, userToken); err == nil {
14+
notifiers = append(notifiers, n)
2715
log.Print("Pushover notification enabled")
2816
}
2917

30-
var err error
3118
botToken := os.Getenv("TELEGRAM_BOT_TOKEN")
3219
telegramChatId := os.Getenv("TELEGRAM_CHAT_ID")
33-
if botToken != "" && telegramChatId != "" {
34-
tgChatId, err = strconv.ParseInt(telegramChatId, 10, 64)
35-
if err == nil {
36-
tgBotApi, err = tgbotapi.NewBotAPI(botToken)
37-
if err == nil {
38-
log.Print("Telegram bot notification enabled")
39-
}
40-
}
20+
if n, err := newTelegramNotifier(botToken, telegramChatId); err == nil {
21+
notifiers = append(notifiers, n)
22+
log.Print("Telegram bot notification enabled")
4123
}
4224
}
4325

4426
func Send(message string) {
4527
log.Print(message)
46-
if pushoverApp != nil {
47-
msg := &pushover.Message{
48-
Title: "Put.io",
49-
Message: message,
50-
Sound: pushover.SoundNone,
51-
Timestamp: time.Now().Unix(),
52-
}
53-
_, _ = pushoverApp.SendMessage(msg, recipient)
54-
}
55-
if tgBotApi != nil {
56-
msg := tgbotapi.NewMessage(tgChatId, message)
57-
_, _ = tgBotApi.Send(msg)
28+
for _, n := range notifiers {
29+
n.send(message)
5830
}
5931
}

0 commit comments

Comments
 (0)