trying to get handler to pause/play
This commit is contained in:
25
Dockerfile
25
Dockerfile
@@ -19,26 +19,19 @@ WORKDIR /packages
|
|||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y curl tar xz-utils && \
|
RUN apt-get update && apt-get install -y python3 curl tar xz-utils && \
|
||||||
if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
|
# Download the platform-independent yt-dlp binary
|
||||||
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_armv7l > yt-dlp && \
|
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp > yt-dlp && \
|
||||||
chmod +x yt-dlp; \
|
# Make yt-dlp executable
|
||||||
elif [ "$TARGETPLATFORM" = "linux/aarch64" ]; then \
|
chmod +x yt-dlp && \
|
||||||
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_aarch64 > yt-dlp && \
|
# Install ffmpeg for media conversions
|
||||||
chmod +x yt-dlp; \
|
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
||||||
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
|
|
||||||
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux_aarch64 > yt-dlp && \
|
|
||||||
chmod +x yt-dlp && \
|
|
||||||
curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz > ffmpeg.tar.xz && \
|
curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz > ffmpeg.tar.xz && \
|
||||||
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz; \
|
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz; \
|
||||||
elif [ "$TARGETPLATFORM" = "linux/x86_64" ] | [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
|
elif [ "$TARGETPLATFORM" = "linux/x86_64" ] || [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
|
||||||
curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux > yt-dlp && \
|
|
||||||
chmod +x yt-dlp && \
|
|
||||||
curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz > ffmpeg.tar.xz && \
|
curl -L https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz > ffmpeg.tar.xz && \
|
||||||
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz; \
|
tar -xJf ffmpeg.tar.xz --wildcards */bin/ffmpeg --transform='s/^.*\///' && rm ffmpeg.tar.xz; \
|
||||||
else \
|
fi
|
||||||
echo "Unsupported platform: $TARGETPLATFORM" && false; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# =========
|
# =========
|
||||||
# Runtime
|
# Runtime
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -15,9 +15,13 @@ help: ## Help command
|
|||||||
backend-up: ## Start the backend containers
|
backend-up: ## Start the backend containers
|
||||||
@docker compose --profile backend up -d
|
@docker compose --profile backend up -d
|
||||||
|
|
||||||
|
up-backend: backend-up
|
||||||
|
|
||||||
backend-down: ## Stop the backend containers
|
backend-down: ## Stop the backend containers
|
||||||
@docker compose --profile backend down
|
@docker compose --profile backend down
|
||||||
|
|
||||||
|
down-backend: backend-down
|
||||||
|
|
||||||
run: ## Run the project
|
run: ## Run the project
|
||||||
@echo "Running project..."
|
@echo "Running project..."
|
||||||
@cargo run
|
@cargo run
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use songbird::Songbird;
|
|||||||
|
|
||||||
use crate::error::{SirenResult, Error as SirenError};
|
use crate::error::{SirenResult, Error as SirenError};
|
||||||
|
|
||||||
|
pub mod mute;
|
||||||
pub mod pause;
|
pub mod pause;
|
||||||
pub mod play;
|
pub mod play;
|
||||||
pub mod resume;
|
pub mod resume;
|
||||||
|
|||||||
@@ -29,13 +29,20 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) {
|
|||||||
// Pause the track
|
// Pause the track
|
||||||
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
|
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
|
||||||
let handler = handler_lock.lock().await;
|
let handler = handler_lock.lock().await;
|
||||||
match handler.queue().pause() {
|
match handler.queue().current() {
|
||||||
Ok(_) => {
|
Some(track) => {
|
||||||
log::debug!("<{guild_id}> Paused the track");
|
match track.pause() {
|
||||||
edit_response(&ctx, &command, format!("Pausing the track")).await;
|
Ok(_) => {
|
||||||
}
|
log::debug!("<{guild_id}> Paused the track");
|
||||||
Err(err) => {
|
edit_response(&ctx, &command, format!("Pausing the track")).await;
|
||||||
edit_response(&ctx, &command, format!("Failed to pause: {}", err)).await;
|
}
|
||||||
|
Err(err) => {
|
||||||
|
edit_response(&ctx, &command, format!("Failed to pause: {}", err)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
edit_response(ctx, command, format!("No track currently being played")).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,13 +29,21 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) {
|
|||||||
// Resume the track
|
// Resume the track
|
||||||
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
|
if let Some(handler_lock) = manager.get(guild_id.to_owned()) {
|
||||||
let handler = handler_lock.lock().await;
|
let handler = handler_lock.lock().await;
|
||||||
match handler.queue().resume() {
|
match handler.queue().current() {
|
||||||
Ok(_) => {
|
Some(track) => {
|
||||||
log::debug!("<{guild_id}> Resumed the track");
|
match track.play() {
|
||||||
edit_response(&ctx, &command, format!("Resuming the track")).await;
|
Ok(_) => {
|
||||||
|
log::debug!("<{guild_id}> Resumed the track");
|
||||||
|
edit_response(&ctx, &command, format!("Resuming the track")).await;
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
edit_response(&ctx, &command, format!("Failed to resume: {}", err)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
None => {
|
||||||
edit_response(&ctx, &command, format!("Failed to resume: {}", err)).await;
|
edit_response(&ctx, &command, format!("No track is currently playing")).await;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ async fn generate_thread_name(oai: &OAI, s: &str, max_chars: usize) -> String {
|
|||||||
let message = ChatCompletionMessage {
|
let message = ChatCompletionMessage {
|
||||||
role: GPTRole::User,
|
role: GPTRole::User,
|
||||||
content: format!(
|
content: format!(
|
||||||
"---\n{}\n---\nSummarize the message above into a concise Discord thread title",
|
"---\n{}\n---\nSummarize the message above into a concise Discord thread title with {} max characters",
|
||||||
s
|
s, max_chars
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
let request = ChatCompletionRequest {
|
let request = ChatCompletionRequest {
|
||||||
model: oai.default_model.clone(),
|
model: "gpt-4o-mini".to_string(),
|
||||||
messages: vec![message],
|
messages: vec![message],
|
||||||
temperature: Some(0.5),
|
temperature: Some(0.5),
|
||||||
top_p: None,
|
top_p: None,
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ impl EventHandler for Handler {
|
|||||||
"stop" => commands::audio::stop::run(&ctx, &command).await,
|
"stop" => commands::audio::stop::run(&ctx, &command).await,
|
||||||
"pause" => commands::audio::pause::run(&ctx, &command).await,
|
"pause" => commands::audio::pause::run(&ctx, &command).await,
|
||||||
"resume" => commands::audio::resume::run(&ctx, &command).await,
|
"resume" => commands::audio::resume::run(&ctx, &command).await,
|
||||||
|
"mute" => commands::audio::mute::run(&ctx, &command).await,
|
||||||
"skip" => commands::audio::skip::run(&ctx, &command).await,
|
"skip" => commands::audio::skip::run(&ctx, &command).await,
|
||||||
"volume" => commands::audio::volume::run(&ctx, &command).await,
|
"volume" => commands::audio::volume::run(&ctx, &command).await,
|
||||||
"schedule" => commands::event::schedule::run(&ctx, &command).await,
|
"schedule" => commands::event::schedule::run(&ctx, &command).await,
|
||||||
@@ -92,6 +93,7 @@ impl EventHandler for Handler {
|
|||||||
commands::audio::stop::register(),
|
commands::audio::stop::register(),
|
||||||
commands::audio::pause::register(),
|
commands::audio::pause::register(),
|
||||||
commands::audio::resume::register(),
|
commands::audio::resume::register(),
|
||||||
|
commands::audio::mute::register(),
|
||||||
commands::audio::skip::register(),
|
commands::audio::skip::register(),
|
||||||
commands::audio::volume::register(),
|
commands::audio::volume::register(),
|
||||||
commands::event::schedule::register(),
|
commands::event::schedule::register(),
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ use crate::bot::handler::Handler;
|
|||||||
|
|
||||||
mod bot;
|
mod bot;
|
||||||
mod data;
|
mod data;
|
||||||
mod dnd;
|
|
||||||
mod error;
|
mod error;
|
||||||
|
|
||||||
pub struct HttpKey;
|
pub struct HttpKey;
|
||||||
|
|||||||
Reference in New Issue
Block a user