Prompt for configs.user.ini creation

This commit is contained in:
NotAndreh
2025-07-13 17:51:08 +02:00
parent 8a050af78e
commit 59b8653573
3 changed files with 29 additions and 6 deletions

2
Cargo.lock generated
View File

@@ -143,7 +143,7 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "steam-ticket-generator"
version = "1.0.0"
version = "1.1.0"
dependencies = [
"base64",
"dialoguer",

View File

@@ -1,7 +1,7 @@
[package]
name = "steam-ticket-generator"
authors = ["NotAndreh"]
version = "1.0.0"
version = "1.1.0"
edition = "2024"
[dependencies]

View File

@@ -1,10 +1,10 @@
use std::{io::Read, time::Duration};
use std::{io::{Read, Write}, time::Duration};
use base64::{prelude::BASE64_STANDARD, Engine};
use dialoguer::{theme::ColorfulTheme, Input};
use base64::{prelude::BASE64_STANDARD, Engine as _};
use dialoguer::theme::ColorfulTheme;
fn main() {
let app_id = Input::<u32>::with_theme(&ColorfulTheme::default())
let app_id = dialoguer::Input::<u32>::with_theme(&ColorfulTheme::default())
.with_prompt("Enter the App ID")
.interact()
.unwrap();
@@ -42,6 +42,19 @@ fn main() {
let steamid = steamworks_sys::SteamAPI_ISteamUser_GetSteamID(user);
println!("Steam ID: {}", steamid);
println!("Encrypted App Ticket: {}", ticket);
let create_config_confirm = dialoguer::Confirm::with_theme(&ColorfulTheme::default())
.with_prompt("Do you want to create configs.user.ini file?")
.default(true)
.interact()
.unwrap();
if create_config_confirm {
match create_config(steamid, &ticket) {
Ok(_) => println!("configs.user.ini created successfully."),
Err(e) => eprintln!("Failed to create configs.user.ini: {}", e),
}
}
}
println!("Press Enter to exit...");
@@ -81,3 +94,13 @@ fn run_callbacks(pipe: i32) -> Option<u64> {
call
}
}
fn create_config(steamid: u64, ticket: &str) -> std::io::Result<()> {
let mut file = std::fs::File::create("configs.user.ini")?;
writeln!(file, "[user::general]")?;
writeln!(file, "account_steamid={}", steamid)?;
writeln!(file, "ticket={}", ticket)?;
Ok(())
}