Crates.io | aerostream |
lib.rs | aerostream |
version | 0.16.5 |
source | src |
created_at | 2023-06-27 14:19:02.092428 |
updated_at | 2024-05-23 06:37:20.403205 |
description | Aerostream is Bluesky client using EventStream. |
homepage | |
repository | https://github.com/shigepon7/aerostream |
max_upload_size | |
id | 901340 |
size | 411,436 |
Aerostream is Bluesky client using EventStream.
It can be used as a library or as a command line tool.
cargo install aerostream -F terminal
aerostream
filters:
- name: <Column Name>
subscribes:
dids:
- <DID to identify the repository to subscribe to>
handles:
- <Handle to identify the repository to subscribe to>
keywords:
includes:
- <Keywords to include in Column even if you are not subscribed>
excludes:
- <Keywords to exclude in Column even if you are subscribed>
langs:
includes:
- <Languages to include in Column even if you are not subscribed>
excludes:
- <Languages to exclude in Column even if you are subscribed>
use std::{
io::{stdout, Write},
time::Duration,
};
use aerostream::Client;
use anyhow::Result;
use chrono::Local;
fn main() -> Result<()> {
let mut client = Client::default();
client.set_timeout(5);
client.connect_ws()?;
for (filter, event) in client.next_event_filtered_all()?.iter() {
let Some(commit) = event.as_commit() else {
continue;
};
let posts = commit.get_post_text();
if posts.is_empty() {
continue;
}
let text = posts.join(" ").replace("\n", " ");
let time = commit.time.with_timezone(&Local).format("%m/%d %H:%M");
let handle = match client.get_repo(&commit.repo) {
Ok(r) => r.handle.clone(),
_ => String::from("UNKNOWN"),
};
let blobs = commit
.blobs
.iter()
.map(|b| b.to_string())
.collect::<Vec<_>>();
print!("{} : {} : {} : {}", filter, time, handle, text);
if !commit.blobs.is_empty() {
println!(" : {}", blobs.join(","));
} else {
println!("");
}
stdout().flush().ok();
}
Ok(())
}