58 Commits

Author SHA1 Message Date
175de4ade9 Update debian:bullseye-slim Docker digest to fdd7556
Some checks failed
tests / fmt (push) Successful in 1m32s
tests / build (push) Successful in 1m30s
tests / clippy (push) Failing after 1m28s
tests / test (push) Successful in 1m33s
tests / pre-commit (push) Successful in 2m24s
2025-04-30 00:00:53 +00:00
de4260dd84 Update renovatebot/github-action action to v41.0.18
All checks were successful
tests / fmt (push) Successful in 42s
tests / build (push) Successful in 1m6s
tests / test (push) Successful in 2m18s
tests / clippy (push) Successful in 59s
tests / pre-commit (push) Successful in 1m0s
deploy / release-image (push) Successful in 1m3s
renovate / renovate (push) Successful in 1m29s
2025-04-01 00:01:28 +00:00
335626312b Update renovatebot/github-action action to v41.0.17
All checks were successful
tests / fmt (push) Successful in 50s
tests / build (push) Successful in 2m23s
tests / test (push) Successful in 1m29s
tests / clippy (push) Successful in 1m22s
tests / pre-commit (push) Successful in 1m5s
deploy / release-image (push) Successful in 9m20s
renovate / renovate (push) Successful in 31s
2025-03-28 00:01:48 +00:00
07a4da73c1 Update actions/setup-python digest to 8d9ed9a
All checks were successful
tests / fmt (push) Successful in 49s
tests / clippy (push) Successful in 54s
tests / test (push) Successful in 1m8s
tests / pre-commit (push) Successful in 43s
deploy / release-image (push) Successful in 43s
tests / build (push) Successful in 2m38s
renovate / renovate (push) Successful in 1m50s
2025-03-27 00:01:24 +00:00
fa1d720d0f Update dependency python to 3.13
All checks were successful
tests / build (push) Successful in 55s
tests / fmt (push) Successful in 1m4s
tests / test (push) Successful in 1m25s
deploy / release-image (push) Successful in 48s
tests / clippy (push) Successful in 2m13s
tests / pre-commit (push) Successful in 3m5s
renovate / renovate (push) Successful in 59s
2025-03-26 00:02:13 +00:00
1ec358ec8f Update Rust crate uuid to v1.16.0
All checks were successful
tests / fmt (push) Successful in 1m17s
tests / clippy (push) Successful in 1m11s
tests / build (push) Successful in 1m18s
tests / test (push) Successful in 1m25s
tests / pre-commit (push) Successful in 1m29s
deploy / release-image (push) Successful in 2m14s
renovate / renovate (push) Successful in 1m12s
2025-03-22 00:01:47 +00:00
624e08f3aa Update Rust crate reqwest to v0.12.15
All checks were successful
tests / fmt (push) Successful in 56s
tests / build (push) Successful in 1m52s
tests / pre-commit (push) Successful in 1m24s
tests / test (push) Successful in 1m42s
tests / clippy (push) Successful in 4m59s
deploy / release-image (push) Successful in 3m54s
renovate / renovate (push) Successful in 1m20s
2025-03-22 01:01:27 +01:00
f4f6a486c9 Update debian:bullseye-slim Docker digest to e4b93db
Some checks are pending
tests / fmt (push) Waiting to run
tests / build (push) Waiting to run
tests / test (push) Waiting to run
tests / clippy (push) Waiting to run
tests / pre-commit (push) Waiting to run
deploy / release-image (push) Waiting to run
renovate / renovate (push) Waiting to run
2025-03-21 00:01:10 +00:00
c354ec0562 Update rust:slim-bullseye Docker digest to 1eca9af
All checks were successful
tests / build (push) Successful in 59s
tests / fmt (push) Successful in 1m8s
tests / test (push) Successful in 1m14s
tests / clippy (push) Successful in 55s
tests / pre-commit (push) Successful in 2m6s
deploy / release-image (push) Successful in 3m31s
renovate / renovate (push) Successful in 1m30s
2025-03-20 00:00:51 +00:00
e0f1abcd9c Update renovatebot/github-action action to v41.0.16
Some checks failed
tests / fmt (push) Successful in 3m27s
tests / clippy (push) Successful in 1m50s
tests / pre-commit (push) Successful in 1m20s
deploy / release-image (push) Failing after 40s
renovate / renovate (push) Failing after 2m50s
tests / test (push) Successful in 5m3s
tests / build (push) Successful in 7m38s
2025-03-18 00:00:51 +00:00
aa302e4bb5 Update Rust crate reqwest to v0.12.14
All checks were successful
tests / fmt (push) Successful in 1m0s
tests / clippy (push) Successful in 1m9s
tests / pre-commit (push) Successful in 46s
tests / test (push) Successful in 1m34s
renovate / renovate (push) Successful in 27s
tests / build (push) Successful in 3m44s
deploy / release-image (push) Successful in 2m29s
2025-03-17 00:04:53 +00:00
c461671bfb Update Rust crate serde to v1.0.219
All checks were successful
tests / fmt (push) Successful in 1m31s
tests / test (push) Successful in 1m55s
tests / build (push) Successful in 1m59s
tests / pre-commit (push) Successful in 1m5s
deploy / release-image (push) Successful in 2m6s
tests / clippy (push) Successful in 5m1s
renovate / renovate (push) Successful in 1m18s
2025-03-17 01:02:17 +01:00
271ec4d323 Update Rust crate async-trait to v0.1.88
Some checks failed
tests / clippy (push) Waiting to run
tests / pre-commit (push) Waiting to run
deploy / release-image (push) Waiting to run
renovate / renovate (push) Waiting to run
tests / build (push) Has been cancelled
tests / fmt (push) Has been cancelled
tests / test (push) Has been cancelled
2025-03-16 00:01:16 +00:00
1e807c121d Update docker/login-action digest to 74a5d14
Some checks failed
tests / fmt (push) Successful in 56s
tests / clippy (push) Successful in 1m58s
tests / pre-commit (push) Successful in 1m57s
tests / build (push) Successful in 2m57s
renovate / renovate (push) Successful in 1m3s
tests / test (push) Failing after 6m22s
deploy / release-image (push) Successful in 5m54s
2025-03-15 00:02:19 +00:00
4293775824 Update Rust crate tokio to v1.44.1
Some checks failed
tests / fmt (push) Successful in 1m2s
tests / build (push) Successful in 5m2s
tests / test (push) Failing after 5m11s
tests / clippy (push) Successful in 2m39s
tests / pre-commit (push) Successful in 2m45s
deploy / release-image (push) Successful in 6m57s
renovate / renovate (push) Successful in 28s
2025-03-13 14:11:29 +00:00
fa8f5f5b04 Update rust:slim-bullseye Docker digest to 7fe28fe
All checks were successful
tests / fmt (push) Successful in 1m32s
tests / build (push) Successful in 2m6s
tests / clippy (push) Successful in 1m37s
tests / test (push) Successful in 1m57s
tests / pre-commit (push) Successful in 1m36s
deploy / release-image (push) Successful in 3m12s
renovate / renovate (push) Successful in 2m14s
2025-03-07 23:29:12 +00:00
4ecf9bf205 Update Rust crate tokio to v1.44.0
All checks were successful
tests / fmt (push) Successful in 1m16s
tests / build (push) Successful in 1m40s
tests / test (push) Successful in 1m46s
tests / clippy (push) Successful in 1m15s
tests / pre-commit (push) Successful in 3m12s
deploy / release-image (push) Successful in 6m36s
renovate / renovate (push) Successful in 17s
2025-03-07 23:15:39 +00:00
5b5ca52c04 enable docker cache
All checks were successful
tests / fmt (push) Successful in 1m14s
tests / clippy (push) Successful in 1m27s
tests / build (push) Successful in 1m34s
tests / test (push) Successful in 1m45s
tests / pre-commit (push) Successful in 3m53s
deploy / release-image (push) Successful in 3m44s
renovate / renovate (push) Successful in 28s
2025-03-05 03:54:53 +01:00
ebb66e21cc use Track::new_with_data
Some checks failed
tests / fmt (push) Successful in 1m31s
tests / clippy (push) Successful in 1m42s
tests / pre-commit (push) Successful in 1m42s
tests / test (push) Successful in 1m55s
tests / build (push) Successful in 1m58s
renovate / renovate (push) Successful in 27s
deploy / release-image (push) Has been cancelled
2025-03-05 03:51:02 +01:00
f240b8f0f6 Merge pull request 'Update docker/build-push-action action to v6' (#31) from renovate/docker-build-push-action-6.x into main
All checks were successful
tests / fmt (push) Successful in 1m37s
tests / clippy (push) Successful in 1m34s
tests / pre-commit (push) Successful in 1m32s
tests / test (push) Successful in 1m45s
renovate / renovate (push) Successful in 26s
deploy / release-image (push) Successful in 3m4s
tests / build (push) Successful in 5m52s
Reviewed-on: #31
2025-03-05 03:37:47 +01:00
65c09c5e85 Merge pull request 'Update Rust crate tracing-subscriber to 0.3' (#23) from renovate/tokio-tracing-monorepo into main
Some checks failed
tests / pre-commit (push) Waiting to run
deploy / release-image (push) Waiting to run
renovate / renovate (push) Waiting to run
tests / clippy (push) Has been cancelled
tests / test (push) Has been cancelled
tests / fmt (push) Has been cancelled
tests / build (push) Has been cancelled
Reviewed-on: #23
2025-03-05 03:37:41 +01:00
c9837e456e Update docker/build-push-action action to v6
All checks were successful
tests / fmt (push) Successful in 57s
tests / clippy (push) Successful in 1m43s
tests / build (push) Successful in 1m55s
tests / pre-commit (push) Successful in 1m42s
tests / test (push) Successful in 2m7s
2025-03-05 02:31:29 +00:00
9efc372f8f Update Rust crate tracing-subscriber to 0.3
All checks were successful
tests / fmt (push) Successful in 1m39s
tests / test (push) Successful in 1m45s
tests / clippy (push) Successful in 1m22s
tests / pre-commit (push) Successful in 1m11s
tests / build (push) Successful in 51s
2025-03-05 02:31:24 +00:00
7ff991206b Merge branch 'main' of gitea:jheuel/ohrwurm
All checks were successful
tests / fmt (push) Successful in 1m26s
tests / clippy (push) Successful in 1m22s
tests / pre-commit (push) Successful in 1m29s
tests / test (push) Successful in 1m40s
renovate / renovate (push) Successful in 1m10s
tests / build (push) Successful in 2m28s
deploy / release-image (push) Successful in 4m13s
2025-03-05 03:28:57 +01:00
b1d6069d81 update twilight, songbird and reqwest 2025-03-05 03:27:43 +01:00
de3262c072 Merge pull request 'Update Rust crate sqlx to 0.8' (#20) from renovate/sqlx-0.x into main
All checks were successful
tests / fmt (push) Successful in 1m11s
tests / clippy (push) Successful in 1m31s
tests / pre-commit (push) Successful in 1m27s
tests / build (push) Successful in 1m47s
tests / test (push) Successful in 1m53s
renovate / renovate (push) Successful in 1m20s
deploy / release-image (push) Successful in 5m8s
Reviewed-on: #20
2025-03-05 02:20:12 +01:00
8e88cadbb8 Update Rust crate sqlx to 0.8
All checks were successful
tests / fmt (push) Successful in 1m30s
tests / build (push) Successful in 1m45s
tests / test (push) Successful in 1m44s
tests / clippy (push) Successful in 1m34s
tests / pre-commit (push) Successful in 1m38s
2025-03-05 01:08:09 +00:00
c6e34cf000 cargo update
Some checks are pending
tests / fmt (push) Successful in 1m1s
tests / build (push) Successful in 1m30s
tests / clippy (push) Successful in 1m20s
tests / pre-commit (push) Successful in 1m7s
tests / test (push) Successful in 1m57s
deploy / release-image (push) Successful in 4m42s
renovate / renovate (push) Waiting to run
2025-03-05 02:04:55 +01:00
3b135894eb Update Rust crate serde_json to v1.0.140
Some checks failed
tests / fmt (push) Failing after 29s
tests / build (push) Successful in 1m42s
tests / clippy (push) Successful in 1m21s
tests / pre-commit (push) Successful in 2m30s
tests / test (push) Failing after 5m37s
renovate / renovate (push) Successful in 37s
deploy / release-image (push) Successful in 3m50s
2025-03-05 01:02:27 +01:00
14cab9d833 Update Rust crate chrono to v0.4.40
Some checks are pending
tests / fmt (push) Waiting to run
tests / build (push) Waiting to run
tests / test (push) Waiting to run
tests / clippy (push) Waiting to run
tests / pre-commit (push) Waiting to run
deploy / release-image (push) Waiting to run
renovate / renovate (push) Waiting to run
2025-03-04 21:37:33 +00:00
f2f4396674 remove docker-compose.yml
All checks were successful
tests / fmt (push) Successful in 1m19s
tests / clippy (push) Successful in 1m13s
tests / build (push) Successful in 1m20s
tests / test (push) Successful in 1m23s
tests / pre-commit (push) Successful in 1m32s
deploy / release-image (push) Successful in 3m39s
renovate / renovate (push) Successful in 2m27s
2025-03-04 22:34:19 +01:00
b60cce35ca Merge branch 'main' of gitea:jheuel/ohrwurm
All checks were successful
tests / fmt (push) Successful in 1m9s
tests / build (push) Successful in 1m35s
tests / clippy (push) Successful in 1m26s
tests / pre-commit (push) Successful in 1m34s
deploy / release-image (push) Successful in 4m0s
tests / test (push) Successful in 1m19s
renovate / renovate (push) Successful in 54s
2025-03-04 11:44:05 +01:00
9f1ed63011 enable renovate automerge 2025-03-04 11:44:00 +01:00
6096e625a2 Merge pull request 'Update Rust crate tokio to v1.43.0' (#21) from renovate/tokio-1.x-lockfile into main
Some checks are pending
tests / fmt (push) Waiting to run
tests / build (push) Waiting to run
tests / test (push) Waiting to run
tests / clippy (push) Waiting to run
tests / pre-commit (push) Waiting to run
deploy / release-image (push) Waiting to run
renovate / renovate (push) Successful in 31s
Reviewed-on: #21
2025-03-04 11:39:12 +01:00
5c42fb9480 Update Rust crate tokio to v1.43.0
All checks were successful
tests / fmt (push) Successful in 1m18s
tests / clippy (push) Successful in 1m25s
tests / build (push) Successful in 1m43s
tests / test (push) Successful in 1m48s
tests / pre-commit (push) Successful in 1m4s
2025-03-04 10:27:46 +00:00
d1df70a888 disable automerge
Some checks failed
renovate / renovate (push) Successful in 31s
tests / fmt (push) Successful in 1m18s
tests / build (push) Successful in 1m17s
tests / clippy (push) Successful in 46s
tests / test (push) Successful in 1m10s
tests / pre-commit (push) Has been cancelled
deploy / release-image (push) Has been cancelled
2025-03-04 11:27:16 +01:00
c4bc5503a5 Update jheuel/ohrwurm:latest Docker digest to b5e0fbc
Some checks are pending
tests / fmt (push) Waiting to run
tests / build (push) Waiting to run
tests / test (push) Waiting to run
tests / clippy (push) Waiting to run
tests / pre-commit (push) Waiting to run
deploy / release-image (push) Waiting to run
renovate / renovate (push) Waiting to run
2025-03-04 10:02:01 +00:00
16f6c97eec Update Rust crate async-trait to v0.1.87
Some checks failed
renovate / renovate (push) Successful in 33s
tests / fmt (push) Successful in 1m11s
tests / build (push) Successful in 1m3s
tests / pre-commit (push) Failing after 1m52s
tests / clippy (push) Successful in 2m7s
tests / test (push) Successful in 2m36s
deploy / release-image (push) Successful in 3m59s
2025-03-04 07:25:52 +00:00
cd42401280 Update rust:slim-bullseye Docker digest to e94e2d2
All checks were successful
renovate / renovate (push) Successful in 33s
tests / fmt (push) Successful in 54s
tests / build (push) Successful in 50s
tests / test (push) Successful in 1m32s
tests / pre-commit (push) Successful in 1m50s
tests / clippy (push) Successful in 2m9s
deploy / release-image (push) Successful in 3m57s
2025-03-04 06:47:43 +00:00
cc0af054f8 Update Rust crate anyhow to v1.0.97
Some checks failed
renovate / renovate (push) Successful in 1m36s
tests / fmt (push) Successful in 1m12s
tests / build (push) Successful in 1m12s
tests / test (push) Successful in 52s
deploy / release-image (push) Failing after 11m45s
tests / pre-commit (push) Failing after 11m47s
tests / clippy (push) Failing after 11m56s
2025-03-03 13:38:02 +00:00
aff5e1dd8d Merge pull request 'Pin dependencies' (#9) from renovate/pin-dependencies into main
All checks were successful
tests / fmt (push) Successful in 35s
tests / clippy (push) Successful in 56s
tests / build (push) Successful in 1m6s
tests / test (push) Successful in 1m11s
tests / pre-commit (push) Successful in 42s
deploy / release-image (push) Successful in 4m13s
renovate / renovate (push) Successful in 1m55s
Reviewed-on: #9
2025-03-03 14:37:03 +01:00
ed9956c5a5 Pin dependencies
All checks were successful
tests / fmt (push) Successful in 2m51s
tests / build (push) Successful in 2m18s
tests / test (push) Successful in 1m54s
tests / clippy (push) Successful in 1m6s
tests / pre-commit (push) Successful in 1m7s
2025-03-03 13:32:53 +00:00
456a51bc70 add renovate
Some checks failed
renovate / renovate (push) Successful in 1m30s
tests / fmt (push) Successful in 2m5s
tests / clippy (push) Successful in 2m30s
tests / build (push) Successful in 2m36s
tests / test (push) Successful in 3m12s
tests / pre-commit (push) Successful in 1m34s
deploy / release-image (push) Has been cancelled
2025-03-03 14:31:29 +01:00
b9b3709bb4 disable arm64 platform
All checks were successful
tests / fmt (push) Successful in 2m2s
tests / pre-commit (push) Successful in 2m8s
tests / clippy (push) Successful in 2m14s
tests / test (push) Successful in 2m32s
tests / build (push) Successful in 2m58s
deploy / release-image (push) Successful in 4m3s
2024-11-28 20:14:37 +01:00
27168c36cf fix clippy warnings
Some checks failed
tests / clippy (push) Successful in 2m35s
tests / pre-commit (push) Successful in 2m43s
tests / fmt (push) Successful in 2m54s
tests / test (push) Successful in 2m54s
tests / build (push) Successful in 3m27s
deploy / release-image (push) Has been cancelled
2024-11-28 19:26:42 +01:00
88d9c1d841 Merge branch 'main' of gitea:jheuel/ohrwurm
Some checks failed
tests / fmt (push) Successful in 1m56s
tests / build (push) Successful in 3m38s
tests / clippy (push) Failing after 3m51s
tests / pre-commit (push) Successful in 3m52s
tests / test (push) Successful in 4m5s
deploy / release-image (push) Has been cancelled
2024-11-28 19:17:29 +01:00
d3a4114347 add arm64 platform 2024-11-28 19:16:14 +01:00
a3e9175ea8 remove ffmpeg
Some checks failed
tests / test (push) Failing after 1m55s
tests / pre-commit (push) Failing after 3m33s
tests / fmt (push) Successful in 7m33s
tests / build (push) Successful in 8m15s
tests / clippy (push) Successful in 8m19s
deploy / release-image (push) Successful in 11m24s
2024-11-27 13:30:29 +01:00
6601396a88 Merge branch 'main' of gitea:jheuel/ohrwurm 2024-11-27 12:35:34 +01:00
687f110416 add query logging 2024-11-27 12:35:24 +01:00
9146ac06a6 add docker-compose.yml
All checks were successful
tests / fmt (push) Successful in 45s
tests / build (push) Successful in 1m11s
tests / clippy (push) Successful in 2m22s
tests / pre-commit (push) Successful in 2m30s
tests / test (push) Successful in 2m43s
deploy / release-image (push) Successful in 5m16s
2024-11-26 21:52:22 +01:00
a25e8ef65f update dependencies
All checks were successful
tests / fmt (push) Successful in 1m3s
tests / build (push) Successful in 3m17s
tests / clippy (push) Successful in 3m54s
tests / test (push) Successful in 4m16s
tests / pre-commit (push) Successful in 5m39s
deploy / release-image (push) Successful in 7m57s
2024-11-26 19:55:49 +01:00
f0337050c1 add error context
All checks were successful
tests / fmt (push) Successful in 36s
tests / build (push) Successful in 2m3s
tests / test (push) Successful in 57s
tests / clippy (push) Successful in 39s
tests / pre-commit (push) Successful in 44s
deploy / release-image (push) Successful in 4m46s
2024-08-09 14:02:42 +02:00
440201e153 fix warning while persisting tracks
All checks were successful
tests / fmt (push) Successful in 36s
tests / build (push) Successful in 2m3s
tests / test (push) Successful in 55s
tests / clippy (push) Successful in 41s
tests / pre-commit (push) Successful in 2m40s
deploy / release-image (push) Successful in 7m2s
2024-08-09 11:18:38 +02:00
f7dca8ff65 improve error handling on play command
All checks were successful
tests / fmt (push) Successful in 1m56s
tests / test (push) Successful in 2m51s
tests / clippy (push) Successful in 2m39s
tests / build (push) Successful in 3m25s
tests / pre-commit (push) Successful in 3m55s
deploy / release-image (push) Successful in 8m5s
2024-08-08 18:04:36 +02:00
1e523502eb add timeouts to http requests
All checks were successful
tests / fmt (push) Successful in 2m5s
tests / clippy (push) Successful in 2m29s
tests / pre-commit (push) Successful in 2m33s
tests / test (push) Successful in 2m44s
tests / build (push) Successful in 2m54s
deploy / release-image (push) Successful in 9m8s
2024-07-04 21:31:40 +02:00
dfd0f9c8c8 cleanup
All checks were successful
tests / build (push) Successful in 1m15s
tests / fmt (push) Successful in 1m44s
tests / clippy (push) Successful in 1m57s
tests / pre-commit (push) Successful in 2m8s
tests / test (push) Successful in 2m19s
deploy / release-image (push) Successful in 5m6s
2024-06-30 11:16:12 +02:00
3242f23f84 play around with input types
All checks were successful
tests / fmt (push) Successful in 1m11s
tests / clippy (push) Successful in 2m24s
tests / pre-commit (push) Successful in 2m23s
tests / build (push) Successful in 2m36s
tests / test (push) Successful in 2m40s
2024-06-27 19:59:15 +02:00
20 changed files with 2218 additions and 1138 deletions

View File

@@ -13,47 +13,47 @@ jobs:
fmt: fmt:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
with: with:
components: rustfmt components: rustfmt
- name: Rustfmt Check - name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1 uses: actions-rust-lang/rustfmt@559aa3035a47390ba96088dffa783b5d26da9326 # v1
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
- name: Build - name: Build
run: cargo build --verbose run: cargo build --verbose
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions/setup-python@v5 - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5
with: with:
python-version: '3.12' python-version: '3.13'
- name: Install yt-dlp - name: Install yt-dlp
run: pip install yt-dlp run: pip install yt-dlp
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
- name: Run tests - name: Run tests
run: cargo test --verbose --all-features run: cargo test --verbose --all-features
clippy: clippy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
with: with:
components: clippy components: clippy
- name: Run clippy - name: Run clippy
@@ -62,13 +62,13 @@ jobs:
pre-commit: pre-commit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions/setup-python@v5 - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5
with: with:
python-version: '3.12' python-version: '3.13'
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
with: with:
components: rustfmt components: rustfmt
- uses: pre-commit/action@v3.0.1 - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

View File

@@ -13,21 +13,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
- name: Set up Docker BuildX - name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v3 uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v5 uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6
with: with:
platforms: | platforms: |
linux/amd64 linux/amd64
push: true push: true
tags: jheuel/ohrwurm:latest tags: jheuel/ohrwurm:latest
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -0,0 +1,32 @@
---
# yamllint disable rule:line-length
name: renovate
on: # yamllint disable-line rule:truthy
schedule:
- cron: "@daily"
push:
branches:
- main
jobs:
renovate:
runs-on: [nas]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Self-hosted Renovate
uses: renovatebot/github-action@c21017a4a2fc9f42953bcc907e375a5a544557ec # v41.0.18
with:
token: ${{ secrets.RENOVATE_TOKEN }}
env-regex: "^(?:RENOVATE_\\w+|LOG_LEVEL|GITHUB_COM_TOKEN)$"
env:
LOG_LEVEL: "info"
GITHUB_COM_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
RENOVATE_PLATFORM: "gitea"
RENOVATE_GIT_AUTHOR: "Renovate Bot <renovate@boosted.science>"
RENOVATE_GIT_EMAIL: "renovate@boosted.science"
RENOVATE_ENDPOINT: "https://gitea.jheuel.boosted.science/api/v1/"
RENOVATE_AUTODISCOVER: "true"
RENOVATE_OPTIMIZE_FOR_DISABLED: "true"

View File

@@ -12,47 +12,47 @@ jobs:
fmt: fmt:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
with: with:
components: rustfmt components: rustfmt
- name: Rustfmt Check - name: Rustfmt Check
uses: actions-rust-lang/rustfmt@v1 uses: actions-rust-lang/rustfmt@559aa3035a47390ba96088dffa783b5d26da9326 # v1
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
- name: Build - name: Build
run: cargo build --verbose run: cargo build --verbose
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions/setup-python@v5 - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5
with: with:
python-version: '3.12' python-version: '3.13'
- name: Install yt-dlp - name: Install yt-dlp
run: pip install yt-dlp run: pip install yt-dlp
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
- name: Run tests - name: Run tests
run: cargo test --verbose --all-features run: cargo test --verbose --all-features
clippy: clippy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
with: with:
components: clippy components: clippy
- name: Run clippy - name: Run clippy
@@ -61,13 +61,13 @@ jobs:
pre-commit: pre-commit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get install -y cmake - run: sudo apt-get install -y cmake
- uses: actions/setup-python@v5 - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5
with: with:
python-version: '3.12' python-version: '3.13'
- uses: actions-rust-lang/setup-rust-toolchain@v1 - uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1
with: with:
components: rustfmt components: rustfmt
- uses: pre-commit/action@v3.0.1 - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

2451
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,21 +6,21 @@ edition = "2021"
license = "MIT" license = "MIT"
[dependencies] [dependencies]
symphonia = { version = "0.5.2", features=["all"] } symphonia = { version = "0.5.2", features=["all", "opt-simd"] }
songbird = { version = "0.4.0", features = ["driver", "gateway", "twilight", "rustls", "builtin-queue"] } songbird = { version = "0.5.0", features = ["driver", "gateway", "twilight", "rustls", "builtin-queue"] }
tokio = { features = ["macros", "rt-multi-thread", "signal", "sync"], version = "1" } tokio = { features = ["macros", "rt-multi-thread", "signal", "sync"], version = "1" }
sqlx = { version = "0.7", features = [ "runtime-tokio", "sqlite", "chrono", "migrate"] } sqlx = { version = "0.8", features = [ "runtime-tokio", "sqlite", "chrono", "migrate"] }
regex = { version = "1", features = ["unicode-case"] } regex = { version = "1", features = ["unicode-case"] }
futures = "0.3" futures = "0.3"
reqwest = "0.11" reqwest = "0.12"
tracing = "0.1" tracing = "0.1"
tracing-subscriber = "0.2" tracing-subscriber = "0.3"
twilight-gateway = "0.15" twilight-gateway = "0.16"
twilight-http = "0.15" twilight-http = "0.16"
twilight-model = "0.15" twilight-model = "0.16"
twilight-standby = "0.15" twilight-standby = "0.16"
twilight-cache-inmemory = "0.15" twilight-cache-inmemory = "0.16"
twilight-util = { version = "0.15", features=["builder"] } twilight-util = { version = "0.16", features=["builder"] }
dotenv = "0.15.0" dotenv = "0.15.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"

View File

@@ -1,5 +1,5 @@
# Build image # Build image
FROM rust:slim-bullseye as build FROM rust:slim-bullseye@sha256:1eca9af45f393ac4669b9b63659529638359575f6268cbd4e6543ddc46c53803 as build
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
build-essential autoconf automake cmake libtool libssl-dev pkg-config build-essential autoconf automake cmake libtool libssl-dev pkg-config
@@ -18,9 +18,9 @@ RUN touch src/main.rs
RUN cargo build --release --locked RUN cargo build --release --locked
# Release image # Release image
FROM debian:bullseye-slim FROM debian:bullseye-slim@sha256:fdd75562fdcde1039c2480a1ea1cd2cf03b18b6e4cb551cabb03bde66ade8a5d
RUN apt-get update && apt-get install -y python3-pip ffmpeg RUN apt-get update && apt-get install -y python3-pip
RUN pip install -U yt-dlp RUN pip install -U yt-dlp
COPY --from=build /app/target/release/ohrwurm . COPY --from=build /app/target/release/ohrwurm .

View File

@@ -1,4 +1,3 @@
-- Add migration script here
CREATE TABLE IF NOT EXISTS tracks CREATE TABLE IF NOT EXISTS tracks
( (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,

25
renovate.json Normal file
View File

@@ -0,0 +1,25 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"timezone": "Europe/Berlin",
"extends": [
"config:recommended",
"helpers:pinGitHubActionDigests",
":configMigration",
":pinDevDependencies",
":dependencyDashboard",
"docker:pinDigests",
"preview:dockerCompose",
"preview:dockerVersions"
],
"packageRules": [
{
"matchUpdateTypes": [
"minor",
"patch",
"pin",
"digest"
],
"automerge": true
}
]
}

View File

@@ -26,7 +26,7 @@ pub(crate) async fn delete(
.http .http
.channel_messages(msg.channel_id) .channel_messages(msg.channel_id)
.before(msg.id) .before(msg.id)
.limit(n)? .limit(n)
.await? .await?
.model() .model()
.await?; .await?;

View File

@@ -1,4 +1,5 @@
use crate::state::State; use crate::state::State;
use anyhow::Context;
use std::error::Error; use std::error::Error;
use tracing::debug; use tracing::debug;
use twilight_model::{ use twilight_model::{
@@ -22,7 +23,7 @@ pub(crate) async fn join_channel(
let channel_id = state let channel_id = state
.cache .cache
.voice_state(user_id, guild_id) .voice_state(user_id, guild_id)
.ok_or("Cannot get voice state for user")? .context("Could not get voice state for user")?
.channel_id(); .channel_id();
// join the voice channel // join the voice channel
@@ -30,12 +31,12 @@ pub(crate) async fn join_channel(
.songbird .songbird
.join(guild_id.cast(), channel_id) .join(guild_id.cast(), channel_id)
.await .await
.map_err(|e| format!("Could not join voice channel: {:?}", e))?; .context("Could not join voice channel")?;
// signal that we are not listening // signal that we are not listening
if let Some(call_lock) = state.songbird.get(guild_id.cast()) { if let Some(call_lock) = state.songbird.get(guild_id.cast()) {
let mut call = call_lock.lock().await; let mut call = call_lock.lock().await;
call.deafen(true).await?; call.deafen(true).await.context("Could not deafen")?;
} }
// create guild config // create guild config

View File

@@ -1,6 +1,7 @@
use crate::metadata::MetadataMap; use crate::metadata::Metadata;
use crate::state::{State, StateRef}; use crate::state::{State, StateRef};
use async_trait::async_trait; use async_trait::async_trait;
use songbird::tracks::Track;
use songbird::{Event, EventContext, EventHandler, TrackEvent}; use songbird::{Event, EventContext, EventHandler, TrackEvent};
use std::ops::Sub; use std::ops::Sub;
use std::time::Duration; use std::time::Duration;
@@ -99,12 +100,11 @@ impl EventHandler for TrackEndNotifier {
let mut call = call_lock.lock().await; let mut call = call_lock.lock().await;
// get metadata from finished track // get metadata from finished track
let old_typemap_lock = track_handle.typemap().read().await; let old_metadata = track_handle.data::<Metadata>();
let old_metadata = old_typemap_lock.get::<MetadataMap>().unwrap();
// enqueue track // enqueue track
let handle = call.enqueue_with_preload( let track = Track::new_with_data(old_metadata.src.clone().into(), old_metadata.clone());
old_metadata.src.clone().into(), let _handle = call.enqueue_with_preload(
track,
old_metadata.duration.map(|duration| -> Duration { old_metadata.duration.map(|duration| -> Duration {
if duration.as_secs() > 5 { if duration.as_secs() > 5 {
duration.sub(Duration::from_secs(5)) duration.sub(Duration::from_secs(5))
@@ -113,10 +113,6 @@ impl EventHandler for TrackEndNotifier {
} }
}), }),
); );
// insert metadata into new track
let mut new_typemap = handle.typemap().write().await;
new_typemap.insert::<MetadataMap>(old_metadata.clone());
} }
None None
} }

View File

@@ -1,26 +1,39 @@
use crate::commands::join::join_channel; use crate::commands::join::join_channel;
use crate::metadata::{Metadata, MetadataMap}; use crate::metadata::Metadata;
use crate::state::State; use crate::state::State;
use crate::{colors, db}; use crate::{colors, db};
use anyhow::Context;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use songbird::input::{Compose, YoutubeDl}; use songbird::input::{Compose, YoutubeDl};
use songbird::tracks::Track; use songbird::tracks::Track;
use std::io::{BufRead, BufReader}; use std::sync::Arc;
use std::ops::Sub;
use std::{error::Error, time::Duration}; use std::{error::Error, time::Duration};
use std::{
io::{BufRead, BufReader},
ops::Sub,
};
use tokio::process::Command; use tokio::process::Command;
use tracing::debug; use tracing::debug;
use twilight_model::channel::message::embed::{ use twilight_model::channel::message::embed::{
EmbedAuthor, EmbedField, EmbedFooter, EmbedThumbnail, EmbedAuthor, EmbedField, EmbedFooter, EmbedThumbnail,
}; };
use twilight_model::channel::message::MessageFlags; use twilight_model::channel::message::{Embed, MessageFlags};
use twilight_model::gateway::payload::incoming::InteractionCreate; use twilight_model::gateway::payload::incoming::InteractionCreate;
use twilight_model::http::interaction::{InteractionResponse, InteractionResponseType}; use twilight_model::http::interaction::{InteractionResponse, InteractionResponseType};
use twilight_util::builder::embed::EmbedBuilder; use twilight_util::builder::embed::EmbedBuilder;
use twilight_util::builder::InteractionResponseDataBuilder; use twilight_util::builder::InteractionResponseDataBuilder;
use url::Url; use url::Url;
#[derive(Debug)]
struct TrackType {
url: String,
title: Option<String>,
duration_string: String,
channel: String,
thumbnail: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
struct YouTubeTrack { struct YouTubeTrack {
url: Option<String>, url: Option<String>,
@@ -30,6 +43,7 @@ struct YouTubeTrack {
playlist: Option<String>, playlist: Option<String>,
playlist_id: Option<String>, playlist_id: Option<String>,
duration_string: String, duration_string: String,
thumbnail: Option<String>,
} }
fn build_playlist_url(playlist_id: &str) -> String { fn build_playlist_url(playlist_id: &str) -> String {
@@ -44,12 +58,18 @@ async fn get_tracks(
.output() .output()
.await?; .await?;
tracing::info!(
"yt-dlp output: {:?}",
String::from_utf8_lossy(&output.stdout)
);
let reader = BufReader::new(output.stdout.as_slice()); let reader = BufReader::new(output.stdout.as_slice());
let tracks: Vec<YouTubeTrack> = reader let tracks: Vec<YouTubeTrack> = reader
.lines() .lines()
.map_while(Result::ok) .map_while(Result::ok)
.flat_map(|line| serde_json::from_str(&line)) .flat_map(|line| serde_json::from_str(&line))
.collect(); .collect();
tracing::info!("yt-dlp tracks: {:?}", tracks);
if tracks.is_empty() { if tracks.is_empty() {
if let Ok(stderr) = String::from_utf8(output.stderr) { if let Ok(stderr) = String::from_utf8(output.stderr) {
@@ -62,22 +82,210 @@ async fn get_tracks(
} }
return Err("No tracks found".into()); return Err("No tracks found".into());
} }
tracing::debug!("tracks: {:?}", tracks); tracing::info!("tracks: {:?}", tracks);
Ok(tracks) Ok(tracks)
} }
async fn persistence(
interaction: &InteractionCreate,
track: &YouTubeTrack,
state: State,
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
let Some(guild_id) = interaction.guild_id else {
return Ok(());
};
let Some(user_id) = interaction.author_id() else {
return Ok(());
};
let url = track
.original_url
.clone()
.or(track.url.clone())
.ok_or("Could not find url")?;
let (author_name, author_global_name) = if let Some(author) = interaction.author() {
(author.name.clone(), author.global_name.clone())
} else {
("".to_string(), None)
};
db::track::insert_guild(&state.pool, db::track::Guild::new(guild_id.to_string()))
.await
.context("failed to insert guild")?;
db::track::insert_user(
&state.pool,
db::track::User::new(user_id.to_string(), author_name, author_global_name),
)
.await
.context("failed to insert user")?;
let track_id = db::track::insert_track(
&state.pool,
db::track::Track::new(
url.clone(),
track.title.clone(),
track.channel.clone(),
track.duration_string.clone(),
track.thumbnail.clone().unwrap_or_default(),
),
)
.await
.context("failed to insert track")?;
db::track::insert_query(
&state.pool,
db::track::Query::new(user_id.to_string(), guild_id.to_string(), track_id),
)
.await
.context("failed to insert query")?;
Ok(())
}
fn build_single_track_added_embeds(tracks_added: &[TrackType]) -> Vec<Embed> {
let track = tracks_added.first().unwrap();
let host = if let Ok(host) = Url::parse(&track.url) {
Some(
host.host_str()
.unwrap_or_default()
.trim_start_matches("www.")
.to_string(),
)
} else {
None
};
let footer = match host {
Some(host) => EmbedFooter {
text: format!("Streaming from {}", host),
icon_url: Some(format!(
"https://www.google.com/s2/favicons?domain={}",
host
)),
proxy_icon_url: None,
},
None => EmbedFooter {
text: String::new(),
icon_url: None,
proxy_icon_url: None,
},
};
let mut embed = EmbedBuilder::new()
.author(EmbedAuthor {
name: "🔊 Added to queue".to_string(),
icon_url: None,
proxy_icon_url: None,
url: None,
})
.title(track.title.clone().unwrap_or("Unknown".to_string()))
.url(track.url.clone())
.color(colors::BLURPLE)
.footer(footer)
.field(EmbedField {
inline: true,
name: "Duration".to_string(),
value: track.duration_string.clone(),
})
.field(EmbedField {
inline: true,
name: "Channel".to_string(),
value: track.channel.clone(),
})
.build();
if let Some(thumbnail) = &track.thumbnail {
embed.thumbnail = Some(EmbedThumbnail {
height: None,
proxy_url: None,
url: thumbnail.to_string(),
width: None,
});
}
vec![embed]
}
fn build_playlist_added_embeds(tracks: &[YouTubeTrack], num_tracks_added: usize) -> Vec<Embed> {
let mut content = String::new();
let first_track = tracks.first().unwrap();
content.push_str(&format!(
"Adding playlist: [{}]({})\n",
&first_track
.playlist
.clone()
.unwrap_or("Unknown".to_string()),
build_playlist_url(
&first_track
.playlist_id
.clone()
.unwrap_or("Unknown".to_string())
)
));
content.push_str(&format!(
"Added {} tracks to the queue.\n",
num_tracks_added
));
let embed = EmbedBuilder::new()
.description(content)
.color(colors::BLURPLE)
.build();
vec![embed]
}
fn build_embeds(tracks: &[YouTubeTrack], tracks_added: &[TrackType]) -> Vec<Embed> {
let num_tracks_added = tracks_added.len();
match num_tracks_added {
0 => vec![],
1 => build_single_track_added_embeds(tracks_added),
_ => build_playlist_added_embeds(tracks, num_tracks_added),
}
}
pub(crate) async fn play( pub(crate) async fn play(
interaction: Box<InteractionCreate>, interaction: Box<InteractionCreate>,
state: State, state: State,
query: String, query: String,
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> { ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
debug!( tracing::info!(
"play command in channel {:?} by {:?}", "play command in channel {:?} by {:?}",
interaction.channel, interaction.channel,
interaction.author(), interaction.author(),
); );
match play_inner(&interaction, Arc::clone(&state), query).await {
Ok(_) => Ok(()),
Err(e) => {
tracing::debug!("Search did not result in any tracks: {}", e);
let content = "Search did not result in any tracks.".to_string();
let embeds = vec![EmbedBuilder::new()
.description(content)
.color(colors::RED)
.build()];
state
.http
.interaction(interaction.application_id)
.update_response(&interaction.token)
.embeds(Some(&embeds))
.await?;
Ok(())
}
}
}
pub(crate) async fn play_inner(
interaction: &InteractionCreate,
state: State,
query: String,
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
tracing::info!(
"play_inner in channel {:?} by {:?}",
interaction.channel,
interaction.author(),
);
let content = format!("Adding track(s) to the queue: {}", query); let content = format!("Adding track(s) to the queue: {}", query);
tracing::info!("content: {:?}", content);
let embeds = vec![EmbedBuilder::new() let embeds = vec![EmbedBuilder::new()
.description(content) .description(content)
.color(colors::YELLOW) .color(colors::YELLOW)
@@ -112,25 +320,10 @@ pub(crate) async fn play(
query query
}; };
debug!("query: {:?}", query); tracing::info!("query: {:?}", query);
let tracks = match get_tracks(query).await { let tracks = get_tracks(query).await?;
Err(e) => { tracing::info!("got tracks: {:?}", tracks);
let content = format!("{}", e);
let embeds = vec![EmbedBuilder::new()
.description(content)
.color(colors::RED)
.build()];
state
.http
.interaction(interaction.application_id)
.update_response(&interaction.token)
.embeds(Some(&embeds))?
.await?;
return Ok(());
}
Ok(tracks) => tracks,
};
if tracks.len() > 1 { if tracks.len() > 1 {
let first_track = tracks.first().unwrap(); let first_track = tracks.first().unwrap();
@@ -155,21 +348,14 @@ pub(crate) async fn play(
.http .http
.interaction(interaction.application_id) .interaction(interaction.application_id)
.update_response(&interaction.token) .update_response(&interaction.token)
.embeds(Some(&embeds))? .embeds(Some(&embeds))
.await?; .await
.context("Could not send playlist loading message")?;
} }
if let Some(call_lock) = state.songbird.get(guild_id) { if let Some(call_lock) = state.songbird.get(guild_id) {
let call = call_lock.lock().await; let call = call_lock.lock().await;
call.queue().resume()?; call.queue().resume().context("Could not resume playing")?;
}
struct TrackType {
url: String,
title: Option<String>,
duration_string: String,
channel: String,
thumbnail: Option<String>,
} }
let mut tracks_added = vec![]; let mut tracks_added = vec![];
@@ -179,51 +365,29 @@ pub(crate) async fn play(
.original_url .original_url
.clone() .clone()
.or(yttrack.url.clone()) .or(yttrack.url.clone())
.ok_or("Could not find url")?; .context("Could not find url")?;
let mut src = YoutubeDl::new(reqwest::Client::new(), url.clone()); let mut src = YoutubeDl::new(state.client.clone(), url.clone());
let src_copy = src.clone();
let track: Track = src_copy.into();
if let Ok(metadata) = src.aux_metadata().await { match src.aux_metadata().await {
Ok(metadata) => {
debug!("metadata: {:?}", metadata); debug!("metadata: {:?}", metadata);
let (author_name, author_global_name) = if let Some(author) = interaction.author() { let track: Track = Track::new_with_data(
(author.name.clone(), author.global_name.clone()) src.clone().into(),
} else { Arc::new(Metadata {
("".to_string(), None) title: metadata.title.clone(),
}; duration: metadata.duration,
url: url.clone(),
src,
}),
);
db::track::insert_guild(&state.pool, db::track::Guild::new(guild_id.to_string())) persistence(interaction, yttrack, Arc::clone(&state))
.await .await
.expect("failed to insert guild: {e}"); .unwrap_or_else(|e| {
tracing::error!("could not persist track: {:?}", e);
db::track::insert_user( });
&state.pool,
db::track::User::new(user_id.to_string(), author_name, author_global_name),
)
.await
.expect("failed to insert user: {e}");
let track_id = db::track::insert_track(
&state.pool,
db::track::Track::new(
url.clone(),
yttrack.title.clone(),
yttrack.channel.clone(),
yttrack.duration_string.clone(),
metadata.thumbnail.clone().unwrap_or_default(),
),
)
.await
.expect("failed to insert track: {e}");
db::track::insert_query(
&state.pool,
db::track::Query::new(user_id.to_string(), guild_id.to_string(), track_id),
)
.await
.expect("failed to insert track: {e}");
tracks_added.push(TrackType { tracks_added.push(TrackType {
url: url.clone(), url: url.clone(),
@@ -233,9 +397,10 @@ pub(crate) async fn play(
thumbnail: metadata.thumbnail.clone(), thumbnail: metadata.thumbnail.clone(),
}); });
if let Some(call_lock) = state.songbird.get(guild_id) { match state.songbird.get(guild_id) {
Some(call_lock) => {
let mut call = call_lock.lock().await; let mut call = call_lock.lock().await;
let handle = call.enqueue_with_preload( let _handle = call.enqueue_with_preload(
track, track,
metadata.duration.map(|duration| -> Duration { metadata.duration.map(|duration| -> Duration {
if duration.as_secs() > 5 { if duration.as_secs() > 5 {
@@ -245,104 +410,41 @@ pub(crate) async fn play(
} }
}), }),
); );
let mut x = handle.typemap().write().await; }
x.insert::<MetadataMap>(Metadata { None => tracing::error!("could not get call lock"),
title: metadata.title,
duration: metadata.duration,
url,
src,
});
} }
} }
} Err(e) => {
let mut content = String::new(); tracing::error!("could not get metadata: {:?}", e);
let num_tracks_added = tracks_added.len(); if e.to_string()
let embeds = match num_tracks_added { .contains("Sign in to confirm youre not a bot.")
0 => { {
vec![] let content =
} "I seem to have been flagged by YouTube as a bot. :-(".to_string();
1 => { let embeds = vec![EmbedBuilder::new()
let track = tracks_added.first().unwrap();
let host = Url::parse(&track.url)?;
let host = host
.host_str()
.unwrap_or_default()
.trim_start_matches("www.");
let mut embed = EmbedBuilder::new()
.author(EmbedAuthor {
name: "🔊 Added to queue".to_string(),
icon_url: None,
proxy_icon_url: None,
url: None,
})
.title(track.title.clone().unwrap_or("Unknown".to_string()))
.url(track.url.clone())
.color(colors::BLURPLE)
.footer(EmbedFooter {
text: format!("Streaming from {}", host),
icon_url: Some(format!(
"https://www.google.com/s2/favicons?domain={}",
host
)),
proxy_icon_url: None,
})
.field(EmbedField {
inline: true,
name: "Duration".to_string(),
value: track.duration_string.clone(),
})
.field(EmbedField {
inline: true,
name: "Channel".to_string(),
value: track.channel.clone(),
})
.build();
if let Some(thumbnail) = &track.thumbnail {
embed.thumbnail = Some(EmbedThumbnail {
height: None,
proxy_url: None,
url: thumbnail.to_string(),
width: None,
});
}
vec![embed]
}
_ => {
let first_track = tracks.first().unwrap();
content.push_str(&format!(
"Adding playlist: [{}]({})\n",
&first_track
.playlist
.clone()
.unwrap_or("Unknown".to_string()),
build_playlist_url(
&first_track
.playlist_id
.clone()
.unwrap_or("Unknown".to_string())
)
));
content.push_str(&format!(
"Added {} tracks to the queue:\n",
num_tracks_added
));
let embed = EmbedBuilder::new()
.description(content) .description(content)
.color(colors::BLURPLE) .color(colors::RED)
.build(); .build()];
vec![embed]
}
};
state state
.http .http
.interaction(interaction.application_id) .interaction(interaction.application_id)
.update_response(&interaction.token) .update_response(&interaction.token)
.embeds(Some(&embeds))? .embeds(Some(&embeds))
.await?; .await?;
return Ok(());
}
}
}
}
let embeds = build_embeds(&tracks, &tracks_added);
state
.http
.interaction(interaction.application_id)
.update_response(&interaction.token)
.embeds(Some(&embeds))
.await
.context("Could not send final play message")?;
Ok(()) Ok(())
} }

View File

@@ -1,6 +1,6 @@
use songbird::tracks::TrackHandle; use songbird::tracks::TrackHandle;
use twilight_model::channel::message::component::{ActionRow, Button, ButtonStyle}; use twilight_model::channel::message::component::{ActionRow, Button, ButtonStyle};
use twilight_model::channel::message::{Component, Embed, MessageFlags, ReactionType}; use twilight_model::channel::message::{Component, Embed, EmojiReactionType, MessageFlags};
use twilight_model::gateway::payload::incoming::InteractionCreate; use twilight_model::gateway::payload::incoming::InteractionCreate;
use twilight_model::http::interaction::InteractionResponse; use twilight_model::http::interaction::InteractionResponse;
use twilight_model::http::interaction::InteractionResponseType; use twilight_model::http::interaction::InteractionResponseType;
@@ -8,7 +8,8 @@ use twilight_util::builder::embed::EmbedBuilder;
use twilight_util::builder::InteractionResponseDataBuilder; use twilight_util::builder::InteractionResponseDataBuilder;
use crate::colors; use crate::colors;
use crate::{metadata::MetadataMap, state::State}; use crate::metadata::Metadata;
use crate::state::State;
use std::error::Error; use std::error::Error;
pub(crate) const TRACKS_PER_PAGE: usize = 5; pub(crate) const TRACKS_PER_PAGE: usize = 5;
@@ -38,10 +39,7 @@ pub(crate) async fn build_queue_embeds(queue: &[TrackHandle], page: usize) -> Ve
.skip(TRACKS_PER_PAGE * page) .skip(TRACKS_PER_PAGE * page)
.take(TRACKS_PER_PAGE) .take(TRACKS_PER_PAGE)
{ {
let map = track.typemap().read().await; let metadata = track.data::<Metadata>();
let metadata = map
.get::<MetadataMap>()
.expect("Could not get metadata map");
message.push_str( message.push_str(
format!( format!(
"* [{}]({})", "* [{}]({})",
@@ -59,7 +57,7 @@ pub(crate) async fn build_queue_embeds(queue: &[TrackHandle], page: usize) -> Ve
} }
message.push('\n'); message.push('\n');
let n_pages = (queue.len() + TRACKS_PER_PAGE - 1) / TRACKS_PER_PAGE; let n_pages = queue.len().div_ceil(TRACKS_PER_PAGE);
if n_pages > 1 { if n_pages > 1 {
message.push_str(&format!("page {}/{}", 1 + page, n_pages)); message.push_str(&format!("page {}/{}", 1 + page, n_pages));
} }
@@ -76,31 +74,34 @@ pub(crate) fn build_action_row(page: usize, n_pages: usize) -> Vec<Component> {
custom_id: Some(format!("page:{}", page as i32 - 1)), custom_id: Some(format!("page:{}", page as i32 - 1)),
style: ButtonStyle::Primary, style: ButtonStyle::Primary,
label: Some("Previous page".to_string()), label: Some("Previous page".to_string()),
emoji: Some(ReactionType::Unicode { emoji: Some(EmojiReactionType::Unicode {
name: "⬅️".to_string(), name: "⬅️".to_string(),
}), }),
url: None, url: None,
disabled: page == 0, disabled: page == 0,
sku_id: None,
}), }),
Component::Button(Button { Component::Button(Button {
custom_id: Some(format!("page:{}", page)), custom_id: Some(format!("page:{}", page)),
style: ButtonStyle::Primary, style: ButtonStyle::Primary,
label: Some("Refresh".to_string()), label: Some("Refresh".to_string()),
emoji: Some(ReactionType::Unicode { emoji: Some(EmojiReactionType::Unicode {
name: "🔄".to_string(), name: "🔄".to_string(),
}), }),
url: None, url: None,
disabled: false, disabled: false,
sku_id: None,
}), }),
Component::Button(Button { Component::Button(Button {
custom_id: Some(format!("page:{}", page + 1)), custom_id: Some(format!("page:{}", page + 1)),
style: ButtonStyle::Primary, style: ButtonStyle::Primary,
label: Some("Next page".to_string()), label: Some("Next page".to_string()),
emoji: Some(ReactionType::Unicode { emoji: Some(EmojiReactionType::Unicode {
name: "➡️".to_string(), name: "➡️".to_string(),
}), }),
url: None, url: None,
disabled: page >= n_pages - 1, disabled: page >= n_pages - 1,
sku_id: None,
}), }),
], ],
})] })]
@@ -146,15 +147,15 @@ pub(crate) async fn queue(
} }
let embeds = build_queue_embeds(&queue, 0).await; let embeds = build_queue_embeds(&queue, 0).await;
let n_pages = (queue.len() + TRACKS_PER_PAGE - 1) / TRACKS_PER_PAGE; let n_pages = queue.len().div_ceil(TRACKS_PER_PAGE);
let action_row = build_action_row(0, n_pages); let action_row = build_action_row(0, n_pages);
state state
.http .http
.interaction(interaction.application_id) .interaction(interaction.application_id)
.update_response(&interaction.token) .update_response(&interaction.token)
.embeds(Some(&embeds))? .embeds(Some(&embeds))
.components(Some(&action_row))? .components(Some(&action_row))
.await?; .await?;
Ok(()) Ok(())

View File

@@ -36,18 +36,29 @@ pub(crate) async fn insert_track(
pool: &sqlx::SqlitePool, pool: &sqlx::SqlitePool,
track: Track, track: Track,
) -> Result<i64, sqlx::Error> { ) -> Result<i64, sqlx::Error> {
let query = let query = r#"
"INSERT OR REPLACE INTO tracks (url, title, channel, duration, thumbnail, updated) VALUES ($1, $2, $3, $4, $5, $6)"; INSERT INTO tracks (url, title, channel, duration, thumbnail, updated)
let res = sqlx::query(query) VALUES (?, ?, ?, ?, ?, ?)
.bind(track.url) ON CONFLICT (url) DO UPDATE SET
title = EXCLUDED.title,
channel = EXCLUDED.channel,
duration = EXCLUDED.duration,
thumbnail = EXCLUDED.thumbnail,
updated = EXCLUDED.updated
RETURNING id
"#;
let id = sqlx::query_scalar(query)
.bind(&track.url)
.bind(track.title) .bind(track.title)
.bind(track.channel) .bind(track.channel)
.bind(track.duration) .bind(track.duration)
.bind(track.thumbnail) .bind(track.thumbnail)
.bind(track.updated) .bind(track.updated)
.execute(pool) .fetch_one(pool)
.await?; .await?;
Ok(res.last_insert_rowid())
Ok(id)
} }
#[derive(Debug, FromRow)] #[derive(Debug, FromRow)]
@@ -70,8 +81,14 @@ impl User {
} }
pub(crate) async fn insert_user(pool: &sqlx::SqlitePool, user: User) -> Result<(), sqlx::Error> { pub(crate) async fn insert_user(pool: &sqlx::SqlitePool, user: User) -> Result<(), sqlx::Error> {
let query = let query = r#"
"INSERT OR REPLACE INTO users (id, name, global_name, updated) VALUES ($1, $2, $3, $4)"; INSERT INTO users (id, name, global_name, updated)
VALUES (?, ?, ?, ?)
ON CONFLICT (id) DO UPDATE SET
name = EXCLUDED.name,
global_name = EXCLUDED.global_name,
updated = EXCLUDED.updated
"#;
sqlx::query(query) sqlx::query(query)
.bind(user.id) .bind(user.id)
.bind(user.name) .bind(user.name)
@@ -105,8 +122,10 @@ impl Query {
} }
pub(crate) async fn insert_query(pool: &sqlx::SqlitePool, q: Query) -> Result<i64, sqlx::Error> { pub(crate) async fn insert_query(pool: &sqlx::SqlitePool, q: Query) -> Result<i64, sqlx::Error> {
let query = let query = r#"
"INSERT OR REPLACE INTO queries (user_id, guild_id, track_id, updated) VALUES ($1, $2, $3, $4)"; INSERT INTO queries (user_id, guild_id, track_id, updated)
VALUES (?, ?, ?, ?)
"#;
let res = sqlx::query(query) let res = sqlx::query(query)
.bind(q.user_id) .bind(q.user_id)
.bind(q.guild_id) .bind(q.guild_id)
@@ -132,15 +151,17 @@ impl Guild {
} }
} }
pub(crate) async fn insert_guild( pub(crate) async fn insert_guild(pool: &sqlx::SqlitePool, guild: Guild) -> Result<(), sqlx::Error> {
pool: &sqlx::SqlitePool, let query = r#"
guild: Guild, INSERT INTO guilds (id, updated)
) -> Result<i64, sqlx::Error> { VALUES (?, ?)
let query = "INSERT OR REPLACE INTO guilds (id, updated) VALUES ($1, $2)"; ON CONFLICT (id) DO UPDATE SET
let res = sqlx::query(query) updated = EXCLUDED.updated
"#;
sqlx::query(query)
.bind(guild.id) .bind(guild.id)
.bind(guild.updated) .bind(guild.updated)
.execute(pool) .execute(pool)
.await?; .await?;
Ok(res.last_insert_rowid()) Ok(())
} }

View File

@@ -14,6 +14,7 @@ use twilight_model::gateway::payload::incoming::InteractionCreate;
use twilight_model::http::interaction::{InteractionResponse, InteractionResponseType}; use twilight_model::http::interaction::{InteractionResponse, InteractionResponseType};
use twilight_util::builder::InteractionResponseDataBuilder; use twilight_util::builder::InteractionResponseDataBuilder;
#[derive(Debug, Clone)]
pub(crate) struct Handler { pub(crate) struct Handler {
state: State, state: State,
} }
@@ -112,7 +113,7 @@ impl Handler {
let call = call_lock.lock().await; let call = call_lock.lock().await;
queue = call.queue().current_queue(); queue = call.queue().current_queue();
} }
let n_pages = (queue.len() + TRACKS_PER_PAGE - 1) / TRACKS_PER_PAGE; let n_pages = queue.len().div_ceil(TRACKS_PER_PAGE);
let page = page.min(n_pages - 1).max(0); let page = page.min(n_pages - 1).max(0);
let embeds = build_queue_embeds(&queue, page).await; let embeds = build_queue_embeds(&queue, page).await;
let action_row = build_action_row(page, n_pages); let action_row = build_action_row(page, n_pages);

View File

@@ -12,18 +12,12 @@ mod utils;
use crate::commands::get_chat_commands; use crate::commands::get_chat_commands;
use dotenv::dotenv; use dotenv::dotenv;
use futures::StreamExt;
use signal::signal_handler;
use songbird::{shards::TwilightMap, Songbird}; use songbird::{shards::TwilightMap, Songbird};
use state::StateRef; use state::StateRef;
use std::{env, error::Error, sync::Arc}; use std::{env, error::Error, str::FromStr, sync::Arc, time::Duration};
use tokio::select;
use tracing::{debug, info}; use tracing::{debug, info};
use twilight_cache_inmemory::InMemoryCache; use twilight_cache_inmemory::InMemoryCache;
use twilight_gateway::{ use twilight_gateway::{Event, EventTypeFlags, Intents, Shard, StreamExt as _};
stream::{self, ShardEventStream},
Intents, Shard,
};
use twilight_http::Client as HttpClient; use twilight_http::Client as HttpClient;
use twilight_model::id::Id; use twilight_model::id::Id;
use twilight_standby::Standby; use twilight_standby::Standby;
@@ -34,16 +28,15 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
println!("Starting up..."); println!("Starting up...");
// Initialize the tracing subscriber.
tracing_subscriber::fmt::init(); tracing_subscriber::fmt::init();
info!("Starting up..."); info!("Starting up...");
let (mut shards, state) = { let (shards, state) = {
let db = env::var("DATABASE_URL").map_err(|_| "DATABASE_URL is not set")?; let db = env::var("DATABASE_URL").map_err(|_| "DATABASE_URL is not set")?;
let options = SqliteConnectOptions::new() let options = SqliteConnectOptions::from_str(&db)
.create_if_missing(true) .expect("could not create options")
.filename(&db); .create_if_missing(true);
let pool = SqlitePoolOptions::new() let pool = SqlitePoolOptions::new()
.max_connections(5) .max_connections(5)
.connect_with(options) .connect_with(options)
@@ -72,7 +65,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
| Intents::MESSAGE_CONTENT; | Intents::MESSAGE_CONTENT;
let config = twilight_gateway::Config::new(token.clone(), intents); let config = twilight_gateway::Config::new(token.clone(), intents);
let shards: Vec<Shard> = let shards: Vec<Shard> =
stream::create_recommended(&http, config, |_, builder| builder.build()) twilight_gateway::create_recommended(&http, config, |_, builder| builder.build())
.await? .await?
.collect(); .collect();
let senders = TwilightMap::new( let senders = TwilightMap::new(
@@ -83,6 +76,11 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
); );
let songbird = Songbird::twilight(Arc::new(senders), user_id); let songbird = Songbird::twilight(Arc::new(senders), user_id);
let cache = InMemoryCache::new(); let cache = InMemoryCache::new();
let client = reqwest::ClientBuilder::new()
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(3600))
.build()
.expect("could not build http client");
( (
shards, shards,
@@ -93,6 +91,7 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
standby: Standby::new(), standby: Standby::new(),
guild_settings: Default::default(), guild_settings: Default::default(),
pool, pool,
client,
}), }),
) )
}; };
@@ -100,36 +99,49 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
info!("Ready to receive events"); info!("Ready to receive events");
let handler = Handler::new(Arc::clone(&state)); let handler = Handler::new(Arc::clone(&state));
let mut stop_rx = signal_handler(); // let mut stop_rx = signal_handler();
let mut stream = ShardEventStream::new(shards.iter_mut()); let mut set = tokio::task::JoinSet::new();
loop {
select! { for shard in shards {
biased; set.spawn(tokio::spawn(runner(shard, handler.clone(), state.clone())));
_ = stop_rx.changed() => {
for guild in state.cache.iter().guilds() {
if let Some(user) = state.cache.current_user() {
if state.cache.voice_state(user.id, guild.id()).is_some() {
debug!("Leaving guild {:?}", guild.id());
state.songbird.leave(guild.id()).await?;
} }
set.join_next().await;
Ok(())
} }
}
// need to grab next event to properly leave voice channels async fn runner(mut shard: Shard, handler: Handler, state: Arc<StateRef>) {
stream.next().await; while let Some(item) = shard.next_event(EventTypeFlags::all()).await {
break; let event = match item {
}, Ok(event) => event,
next = stream.next() => { Err(source) => {
let event = match next {
Some((_, Ok(event))) => event,
Some((_, Err(source))) => {
tracing::warn!(?source, "error receiving event"); tracing::warn!(?source, "error receiving event");
if source.is_fatal() {
break;
}
continue; continue;
} }
None => break,
}; };
tokio::spawn({
let state = state.clone();
let handler = handler.clone();
async move {
handle_event(event, handler, state)
.await
.unwrap_or_else(|source| {
tracing::warn!(?source, "error handling event");
});
}
});
}
}
async fn handle_event(
event: Event,
handler: Handler,
state: Arc<StateRef>,
) -> Result<(), Box<dyn Error>> {
state.standby.process(&event);
state.songbird.process(&event).await;
debug!("Event: {:?}", &event); debug!("Event: {:?}", &event);
state.cache.update(&event); state.cache.update(&event);
@@ -137,8 +149,5 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
state.songbird.process(&event).await; state.songbird.process(&event).await;
handler.act(event).await?; handler.act(event).await?;
}
}
}
Ok(()) Ok(())
} }

View File

@@ -1,4 +1,4 @@
use songbird::{input::YoutubeDl, typemap::TypeMapKey}; use songbird::input::YoutubeDl;
use std::time::Duration; use std::time::Duration;
#[derive(Clone)] #[derive(Clone)]
@@ -6,10 +6,5 @@ pub(crate) struct Metadata {
pub(crate) title: Option<String>, pub(crate) title: Option<String>,
pub(crate) duration: Option<Duration>, pub(crate) duration: Option<Duration>,
pub(crate) url: String, pub(crate) url: String,
pub(crate) src: YoutubeDl, pub(crate) src: YoutubeDl<'static>,
}
pub(crate) struct MetadataMap;
impl TypeMapKey for MetadataMap {
type Value = Metadata;
} }

View File

@@ -1,21 +1,21 @@
use tokio::{ // use tokio::{
select, // select,
signal::unix::{signal, SignalKind}, // signal::unix::{signal, SignalKind},
sync::watch, // sync::watch,
}; // };
pub(crate) fn signal_handler() -> watch::Receiver<()> { // pub(crate) fn signal_handler() -> watch::Receiver<()> {
let (stop_tx, stop_rx) = watch::channel(()); // let (stop_tx, stop_rx) = watch::channel(());
tokio::spawn(async move { // tokio::spawn(async move {
let mut sigterm = signal(SignalKind::terminate()).unwrap(); // let mut sigterm = signal(SignalKind::terminate()).unwrap();
let mut sigint = signal(SignalKind::interrupt()).unwrap(); // let mut sigint = signal(SignalKind::interrupt()).unwrap();
loop { // loop {
select! { // select! {
_ = sigterm.recv() => println!("Receive SIGTERM"), // _ = sigterm.recv() => println!("Receive SIGTERM"),
_ = sigint.recv() => println!("Receive SIGTERM"), // _ = sigint.recv() => println!("Receive SIGTERM"),
}; // };
stop_tx.send(()).unwrap(); // stop_tx.send(()).unwrap();
} // }
}); // });
stop_rx // stop_rx
} // }

View File

@@ -33,4 +33,5 @@ pub(crate) struct StateRef {
pub(crate) standby: Standby, pub(crate) standby: Standby,
pub(crate) guild_settings: DashMap<Id<GuildMarker>, Settings>, pub(crate) guild_settings: DashMap<Id<GuildMarker>, Settings>,
pub(crate) pool: sqlx::SqlitePool, pub(crate) pool: sqlx::SqlitePool,
pub(crate) client: reqwest::Client,
} }