feat: authlite command

This commit is contained in:
mokurin000
2025-07-30 13:14:06 +08:00
parent 82e30c020d
commit d3c3592e67
7 changed files with 78 additions and 22 deletions

View File

@@ -9,6 +9,7 @@ description = "CLI tool for SDGB protocol"
snafu = { workspace = true }
sdgb-api = { workspace = true }
serde_json = { workspace = true }
strum = { workspace = true }
nyquest-preset = { version = "0.2.0", features = ["async"] }
compio = { version = "0.15.0", default-features = false, features = [

View File

@@ -1,5 +1,6 @@
use palc::Parser;
use palc::Subcommand;
use strum::EnumString;
#[derive(Parser)]
#[command(about = "SDGB api tool", long_about = env!("CARGO_PKG_DESCRIPTION"))]
@@ -8,8 +9,28 @@ pub struct Cli {
pub command: Commands,
}
#[derive(EnumString)]
pub enum AuthLiteVariant {
SDGB,
SDHJ,
}
#[derive(Subcommand)]
pub enum Commands {
/// Login with QRCode from wechat
QRLogin {
/// content of the qrcode, only the last 64 characters were used
#[arg(short, long)]
qrcode_content: String,
},
AuthLite {
#[arg(short, long, default_value = "1.50")]
title_ver: String,
#[arg(long, default_value = "SDGB")]
variant: AuthLiteVariant,
},
Ping,
Preview {
#[arg(short, long)]
@@ -19,10 +40,4 @@ pub enum Commands {
#[arg(short, long)]
user_id: u32,
},
/// Login with QRCode from wechat
QRLogin {
/// content of the qrcode, only the last 64 characters were used
#[arg(short, long)]
qrcode_content: String,
},
}

View File

@@ -2,6 +2,7 @@ use nyquest_preset::nyquest::ClientBuilder;
use palc::Parser;
use sdgb_api::{
all_net::QRCode,
auth_lite::{SDGB, SDHJ, delivery_raw},
title::{
MaiVersionExt, Sdgb1_40, Sdgb1_50,
methods::APIMethod,
@@ -69,6 +70,14 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
Err(e) => error!("login failed: {e}"),
}
}
commands::Commands::AuthLite { title_ver, variant } => {
let resp = match variant {
commands::AuthLiteVariant::SDGB => delivery_raw::<SDGB>(&client, title_ver).await?,
commands::AuthLiteVariant::SDHJ => delivery_raw::<SDHJ>(&client, title_ver).await?,
};
println!("{}", String::from_utf8_lossy(&resp));
}
}
Ok(())