#![no_std]
use standard_plugin::daemon::{Context, DaemonPlugin};
#[standard_plugin::daemon]
struct Status;
impl DaemonPlugin for Status {
fn activate(_cx: &Context) -> Self {
Self
}
async fn run(&self, cx: Context) {
loop {
#[cfg(target_arch = "wasm32")]
{
use standard_plugin::daemon::http::Request;
let response = Request::get("https://api.github.com/zen")
.header("accept", "text/plain")
.header("user-agent", "standard-plugin-example")
.timeout_ms(10_000)
.max_body(4 * 1024)
.send()
.await;
if let Ok(response) = response
&& response.ok()
&& let Ok(text) = response.text()
{
let _ = cx.live().publish("status.zen", text);
}
}
cx.sleep(5 * 60_000).await;
}
}
}