1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
pub mod challenge; pub mod client; pub mod error; pub mod message; pub use crate::{ client::{ Client, Context, Handler, }, error::{ KahootError, KahootResult, }, message::Message, }; pub use async_trait::async_trait; const USER_AGENT_STR: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36"; #[derive(Debug)] pub struct LoginResponse { pub error: Option<String>, pub description: Option<String>, pub cid: Option<String>, } impl LoginResponse { pub fn from_value(value: &serde_json::Value) -> Option<Self> { if value.get("type")?.as_str()? != "loginResponse" { return None; } let error = value .get("error") .and_then(|s| s.as_str()) .map(|s| s.to_string()); let description = value .get("description") .and_then(|s| s.as_str()) .map(|s| s.to_string()); let cid = value .get("cid") .and_then(|s| s.as_str()) .map(|s| s.to_string()); Some(Self { error, description, cid, }) } }