feat: preview user info

This commit is contained in:
mokurin000
2025-07-30 03:57:51 +08:00
parent 704be45e00
commit 5ea8ebbf64
8 changed files with 106 additions and 3 deletions

View File

@@ -11,6 +11,10 @@ pub struct Cli {
#[derive(Subcommand)]
pub enum Commands {
Ping,
Preview {
#[arg(short, long)]
user_id: u32,
},
/// Login with QRCode from wechat
QRLogin {
/// content of the qrcode, only the last 64 characters were used

View File

@@ -2,7 +2,11 @@ use nyquest_preset::nyquest::ClientBuilder;
use palc::Parser;
use sdgb_api::{
all_net::QRCode,
title::{MaiVersionExt, Sdgb1_40, Sdgb1_50, methods::APIMethod, model::Ping},
title::{
MaiVersionExt, Sdgb1_40, Sdgb1_50,
methods::APIMethod,
model::{GetUserPreviewApi, GetUserPreviewApiResp, Ping},
},
};
use spdlog::{error, info};
@@ -18,8 +22,26 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
let client = ClientBuilder::default().build_async().await?;
match cmd.command {
commands::Commands::Preview { user_id } => {
let preview = Sdgb1_50::request(
&client,
APIMethod::GetUserPreviewApi,
user_id,
GetUserPreviewApi { user_id },
)
.await?;
let preview: GetUserPreviewApiResp = serde_json::from_slice(&preview)?;
println!("{preview}");
}
commands::Commands::Ping => {
let decoded = Sdgb1_40::request(&client, APIMethod::Ping, "", Ping {}).await?;
let decoded = Sdgb1_40::request(
&client,
APIMethod::Ping,
"",
Ping {}, // note: must not be `Ping`, or serde_json serializes to nothing
)
.await?;
info!("sdgb 1.40 resp: {:?}", String::from_utf8_lossy(&decoded));
let decoded = Sdgb1_50::request(&client, APIMethod::Ping, "", Ping {}).await?;
info!("sdgb 1.50 resp: {:?}", String::from_utf8_lossy(&decoded));