Compare commits

..

No commits in common. "614b40ca08ea68b227c0685922e0f2b2a4c3d6d9" and "ffea97668ae6dc64794ab3ffcaed360c96a8a70e" have entirely different histories.

3 changed files with 4 additions and 6 deletions

View File

@ -63,24 +63,20 @@ pub async fn event_handler(
let http_response = request(data.server.api_address()) let http_response = request(data.server.api_address())
.await .await
.expect("Error executing request"); .expect("Error executing request");
trace!("Got HTTP response");
let results = data.server.parse( let results = data.server.parse(
http_response http_response
.text() .text()
.await .await
.expect("Response had no body text"), .expect("Response had no body text"),
); );
trace!("Parsed response");
match &results { match &results {
ServerResponse::Offline => { ServerResponse::Offline => {
info!("Got status: Offline");
ctx.set_presence( ctx.set_presence(
Some(ActivityData::custom("Server offline!")), Some(ActivityData::custom("Server offline!")),
serenity::OnlineStatus::DoNotDisturb, serenity::OnlineStatus::DoNotDisturb,
); );
} }
ServerResponse::Online(online_info) => { ServerResponse::Online(online_info) => {
info!("Got status: Online");
ctx.set_presence( ctx.set_presence(
Some(ActivityData::custom(format!( Some(ActivityData::custom(format!(
"{}/{} online, v{}", "{}/{} online, v{}",

View File

@ -13,7 +13,6 @@ use std::path::Path;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
env_logger::init(); env_logger::init();
info!("Starting up!");
let config = config_parser::parse_configs(Path::new("config.json")) let config = config_parser::parse_configs(Path::new("config.json"))
.expect("Could not parse config.json"); .expect("Could not parse config.json");
info!("Got config file"); info!("Got config file");

View File

@ -6,6 +6,9 @@ const USER_AGENT: &str = "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36
pub async fn request(url: Url) -> Result<Response, reqwest::Error> { pub async fn request(url: Url) -> Result<Response, reqwest::Error> {
let client = reqwest::Client::new(); let client = reqwest::Client::new();
let mut request = reqwest::Request::new(reqwest::Method::GET, url); let mut request = reqwest::Request::new(reqwest::Method::GET, url);
request.headers_mut().append("User-Agent", HeaderValue::from_str(USER_AGENT).expect("Could not build header")); request.headers_mut().append(
"User-Agent",
HeaderValue::from_str(USER_AGENT).expect("Could not build header"),
);
client.execute(request).await client.execute(request).await
} }