Consume injected caller version through and blend into own

This commit is contained in:
Xyon 2023-08-24 09:59:08 +01:00
parent f4914adec7
commit 1832ee94ef
Signed by: xyon
GPG Key ID: DD18155D6B18078D
1 changed files with 4 additions and 1 deletions

View File

@ -64,12 +64,13 @@ pub struct ManifoldDataInner {
database: Db, database: Db,
responses: Responses, responses: Responses,
user_info: Mutex<ManifoldUserInfo>, user_info: Mutex<ManifoldUserInfo>,
version_string: String,
} }
pub type ManifoldContext<'a> = poise::Context<'a, ManifoldData, ManifoldError>; pub type ManifoldContext<'a> = poise::Context<'a, ManifoldData, ManifoldError>;
pub type ManifoldCommand = poise::Command<ManifoldData, ManifoldError>; pub type ManifoldCommand = poise::Command<ManifoldData, ManifoldError>;
pub async fn prepare_client(arguments: ArgMatches, intents: GatewayIntents, injected_commands: Vec<ManifoldCommand>) -> ManifoldResult<FrameworkBuilder<ManifoldData, ManifoldError>> { pub async fn prepare_client(arguments: ArgMatches, intents: GatewayIntents, injected_commands: Vec<ManifoldCommand>, caller_version_string: String) -> ManifoldResult<FrameworkBuilder<ManifoldData, ManifoldError>> {
let bot_environment = arguments.get_one("environment").unwrap(); let bot_environment = arguments.get_one("environment").unwrap();
let config_file = format!("config/{}", arguments.get_one::<String>("config-file").unwrap()); let config_file = format!("config/{}", arguments.get_one::<String>("config-file").unwrap());
@ -119,11 +120,13 @@ pub async fn prepare_client(arguments: ArgMatches, intents: GatewayIntents, inje
let db = Db { pool }; let db = Db { pool };
apply_migrations(&mut db.get()?); apply_migrations(&mut db.get()?);
let user_info = UserInfo::load(&db).expect("Could not load user info, rejecting"); let user_info = UserInfo::load(&db).expect("Could not load user info, rejecting");
let git_info: String = built_info::GIT_VERSION.unwrap_or("unknown").to_string();
Ok(ManifoldData(Arc::new(ManifoldDataInner { Ok(ManifoldData(Arc::new(ManifoldDataInner {
bot_config: config, bot_config: config,
database: db, database: db,
responses, responses,
user_info: Mutex::new(user_info), user_info: Mutex::new(user_info),
version_string: format!("{caller} (Manifold framework version {mfold_ver} built at {mfold_time} from revision {mfold_rev})", caller=caller_version_string, mfold_ver=built_info::PKG_VERSION, mfold_time=built_info::BUILT_TIME_UTC, mfold_rev=git_info),
}))) })))
}) })
}); });