Update dependency to fix build
ci/woodpecker/tag/container Pipeline failed Details

main
trivernis 10 months ago
parent e6726e41c8
commit 2d869f3ea8
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -10,6 +10,13 @@ steps:
test:
image: rust:alpine
commands:
- apk add --no-cache --force-overwrite \
build-base \
openssl-dev \
libopusenc-dev \
libpq-dev \
curl \
bash
- rustup default stable
- rustup component add clippy --toolchain stable-x86_64-unknown-linux-musl
- cargo clippy
@ -20,6 +27,13 @@ steps:
build:
image: rust:alpine
commands:
- apk add --no-cache --force-overwrite \
build-base \
openssl-dev \
libopusenc-dev \
libpq-dev \
curl \
bash
- cargo build
when:
- event: [pull_request]

2263
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -3,7 +3,7 @@ members=["bot-coreutils", "bot-database", "bot-database/migration", "."]
[package]
name = "tobi-rs"
version = "0.11.1"
version = "0.11.2"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"
@ -32,7 +32,7 @@ chrono = "0.4.22"
sysinfo = "0.26.4"
reqwest = "0.11.12"
chrono-tz = "0.6.3"
sauce-api = "0.9.3"
sauce-api = "1.0.0"
rustc_version_runtime = "0.2.1"
trigram = "0.4.4"
typemap_rev = "0.2.0"

@ -22,7 +22,7 @@ COPY Cargo.toml Cargo.lock ./
COPY src ./src
COPY bot-coreutils ./bot-coreutils
COPY bot-database ./bot-database
RUN cargo build --release --verbose
RUN cargo build --release
RUN mkdir /tmp/tobi
RUN cp target/release/tobi-rs /tmp/tobi/
@ -37,9 +37,9 @@ RUN apk add --no-cache --force-overwrite \
qalc \
ffmpeg \
bash
RUN pip3 install youtube-dl
RUN pip3 install yt-dlp --break-system-packages
RUN rm -rf /var/lib/{cache,log}/ /var/cache
FROM runtime-base
COPY --from=builder /tmp/tobi/tobi-rs .
ENTRYPOINT ["/tobi-rs"]
ENTRYPOINT ["/tobi-rs"]

@ -30,7 +30,7 @@ pub async fn get_client() -> BotResult<Client> {
.event_handler(Handler)
.framework(get_framework().await)
.register_songbird()
.type_map_insert::<Store>(StoreData::new())
.type_map_insert::<Store>(StoreData::create().await)
.type_map_insert::<DatabaseContainer>(database)
.type_map_insert::<MusicPlayers>(HashMap::new())
.await?;

@ -1,4 +1,5 @@
use futures::future::BoxFuture;
use futures::FutureExt;
use serenity::client::Context;
use serenity::framework::standard::macros::command;
use serenity::framework::standard::{Args, CommandResult};

@ -1,4 +1,4 @@
use sauce_api::Sauce;
use sauce_api::source::Source;
use serenity::client::Context;
use serenity::framework::standard::macros::command;
use serenity::framework::standard::CommandResult;
@ -59,15 +59,20 @@ async fn sauce(ctx: &Context, msg: &Message) -> CommandResult {
);
let data = ctx.data.read().await;
let store_data = data.get::<Store>().unwrap();
let sources = store_data
.sauce_nao
.check_sauces(&attachment_urls[..])
.await?;
tracing::trace!("Sources are {:?}", sources);
let mut outputs = Vec::new();
tracing::debug!("Creating menu...");
for attachment in attachment_urls {
let output = store_data
.sauce_nao
.check(&attachment)
.await
.map_err(|_| "failed to retrieve source")?;
tracing::trace!("Output is {:?}", output);
outputs.push(output)
}
show_sauce_menu(ctx, msg, sources).await?;
tracing::debug!("Creating menu...");
show_sauce_menu(ctx, msg, outputs).await?;
tracing::debug!("Menu created");
Ok(())

@ -1,6 +1,5 @@
use std::cmp::Ordering;
use sauce_api::{SauceItem, SauceResult};
use serenity::builder::CreateMessage;
use serenity::{model::channel::Message, prelude::*};
@ -24,7 +23,7 @@ static SAUCE_MESSAGES: &[&str] = &[
pub async fn show_sauce_menu(
ctx: &Context,
msg: &Message,
sources: Vec<SauceResult>,
sources: Vec<sauce_api::source::Output>,
) -> BotResult<()> {
let pages: Vec<Page> = sources.into_iter().map(create_sauce_page).collect();
@ -47,7 +46,7 @@ pub async fn show_sauce_menu(
}
/// Creates a single sauce page
fn create_sauce_page<'a>(mut result: SauceResult) -> Page<'a> {
fn create_sauce_page<'a>(mut result: sauce_api::source::Output) -> Page<'a> {
let mut message = CreateMessage::default();
let mut description_lines = Vec::new();
let original = result.original_url;
@ -65,7 +64,7 @@ fn create_sauce_page<'a>(mut result: SauceResult) -> Page<'a> {
});
// display with descending similarity
result.items.reverse();
let items: Vec<(usize, SauceItem)> = result
let items: Vec<(usize, sauce_api::source::Item)> = result
.items
.into_iter()
.filter(|i| i.similarity >= MIN_SIMILARITY)

@ -3,7 +3,8 @@ use std::env;
use std::sync::Arc;
use bot_database::Database;
use sauce_api::prelude::SauceNao;
use sauce_api::source::saucenao::SauceNao;
use sauce_api::source::Source;
use serenity::client::Context;
use serenity::prelude::TypeMapKey;
use tokio::sync::Mutex;
@ -16,15 +17,17 @@ pub struct Store;
pub struct StoreData {
pub minecraft_data_api: minecraft_data_rs::api::Api,
pub spotify_api: SpotifyApi,
pub sauce_nao: SauceNao<'static>,
pub sauce_nao: SauceNao,
}
impl StoreData {
pub fn new() -> StoreData {
let mut sauce_nao = SauceNao::new();
sauce_nao.set_api_key(
pub async fn create() -> StoreData {
let sauce_nao = SauceNao::create(
env::var("SAUCENAO_API_KEY").expect("No SAUCENAO_API_KEY key in environment."),
);
)
.await
.unwrap();
Self {
minecraft_data_api: minecraft_data_rs::api::Api::latest().unwrap(),
spotify_api: SpotifyApi::new(),

Loading…
Cancel
Save