feat: early steps of storage and configuration

This commit is contained in:
2026-04-09 22:39:02 -04:00
parent 7d3a309d2b
commit 7885526944
14 changed files with 393 additions and 54 deletions

View File

@@ -1,55 +1,19 @@
use clap::Parser;
use fomo_reducer::{CommandRouter, State, all_commands, initialize_vcs, update_vcs};
use opendal::{IntoOperatorUri, Operator, OperatorUri};
use fomo_reducer::{CommandRouter, State, Storage, all_commands, initialize_vcs, update_vcs};
use secrecy::{ExposeSecret, SecretString};
use snafu::Snafu;
use songbird::{Songbird, shards::TwilightMap};
use std::{fmt::Debug, str::FromStr, sync::Arc};
use std::{fmt::Debug, sync::Arc};
use tokio::{select, signal::ctrl_c, task::JoinSet};
use tokio_util::{sync::CancellationToken, time::FutureExt as _};
use tracing_subscriber::{EnvFilter, fmt::format::FmtSpan};
use twilight_gateway::{Event, EventTypeFlags, Intents, Shard, ShardId, StreamExt};
use twilight_gateway::{Event, EventTypeFlags, Intents, Shard, StreamExt};
use twilight_model::{
application::interaction::InteractionData,
gateway::payload::incoming::InteractionCreate,
id::{Id, marker::UserMarker},
};
#[derive(Clone)]
struct Storage {
uri: OperatorUri,
operator: Operator,
}
impl FromStr for Storage {
type Err = opendal::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let uri = s.into_operator_uri()?;
let operator = Operator::from_uri(&uri)?;
Ok(Self { uri, operator })
}
}
impl Storage {
fn into_inner(self) -> Operator {
self.operator
}
}
impl From<Storage> for Operator {
fn from(wrapper: Storage) -> Self {
wrapper.into_inner()
}
}
impl Debug for Storage {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&self.uri, f)
}
}
#[derive(Debug, Parser)]
struct AppArgs {
#[arg(long, env)]
@@ -198,13 +162,20 @@ async fn main() -> Result<(), MainError> {
let songbird = Arc::new(songbird);
let vcs = Arc::new(vcs);
let bot_data = bot_data.into_inner();
let recording_data = recording_data.into_inner();
let user_data = user_data.into_inner();
let state = State {
bot_data,
cancellation_token: cancellation_token.clone(),
discord_application_id,
discord_bot_owner_user_id: bot_owner,
discord_client,
discord_user_id,
recording_data,
songbird,
user_data,
vcs,
};