thread tts

This commit is contained in:
mii
2022-11-18 09:08:27 +00:00
parent 708b6fc429
commit b7a4da7f3e
3 changed files with 33 additions and 18 deletions

View File

@ -1,18 +1,18 @@
FROM ubuntu:22.04
WORKDIR /usr/src/ncb-tts-r2
COPY Cargo.toml .
COPY src src
ENV PATH $PATH:/root/.cargo/bin/
RUN apt-get update \
&& apt-get install -y ffmpeg libssl-dev pkg-config libopus-dev wget curl gcc \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/* \
&& curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable \
&& rustup install stable \
&& cargo build --release \
&& rustup install stable
COPY Cargo.toml .
COPY src src
RUN cargo build --release \
&& cp /usr/src/ncb-tts-r2/target/release/ncb-tts-r2 /usr/bin/ncb-tts-r2 \
&& mkdir -p /ncb-tts-r2/audio \
&& apt-get purge -y pkg-config wget curl gcc \
&& rustup self uninstall -y
WORKDIR /ncb-tts-r2
CMD ["ncb-tts-r2"]
CMD ["ncb-tts-r2"]

View File

@ -70,7 +70,7 @@ pub async fn setup_command(
.clone()
};
{
let thread_id = {
let mut storage = storage_lock.write().await;
if storage.contains_key(&guild.id) {
command
@ -84,28 +84,43 @@ pub async fn setup_command(
return Ok(());
}
let message = command
.channel_id
.send_message(&ctx.http, |f| f.content("TTS thread"))
.await
.unwrap();
let thread_id = command
.channel_id
.create_public_thread(&ctx.http, message, |f| {
f.name("TTS").auto_archive_duration(60)
})
.await
.unwrap();
storage.insert(
guild.id,
TTSInstance {
before_message: None,
guild: guild.id,
text_channel: command.channel_id,
text_channel: thread_id.id,
voice_channel: channel_id,
},
);
}
thread_id
};
let _handler = manager.join(guild.id.0, channel_id.0).await;
command
.create_interaction_response(&ctx.http, |f| {
f.interaction_response_data(|d| d.content("."))
})
.await?;
command.create_interaction_response(&ctx.http, |f| {
f.interaction_response_data(|d| {
d.embed(|e| {
e.title("読み上げ (Serenity)")
thread_id.send_message(&ctx.http, |f| f.embed(|e| e.title("読み上げ (Serenity)")
.field("クレジット", "```\n四国めたん  ずんだもん\n春日部つむぎ 雨晴はう\n波音リツ   玄野武宏\n白上虎太郎  青山龍星\n冥鳴ひまり  九州そら\nモチノ・キョウコ```", false)
.field("設定コマンド", "`/config`", false)
})
})
}).await?;
)).await?;
Ok(())
}

View File

@ -7,10 +7,10 @@ pub async fn ready(ctx: Context, ready: Ready) {
println!("{} is connected!", ready.user.name);
let _ = Command::set_global_application_commands(&ctx.http, |commands| {
commands.create_application_command(|command| command.name("stop").description("Stop tts"));
commands
.create_application_command(|command| command.name("setup").description("Setup tts"));
commands.create_application_command(|command| command.name("config").description("Config"))
.create_application_command(|command| command.name("stop").description("Stop tts"))
.create_application_command(|command| command.name("setup").description("Setup tts"))
.create_application_command(|command| command.name("config").description("Config"))
})
.await;
}