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
58
59
60
61
62
//! Aerostream
//! ===
//!
//! Aerostream is Bluesky client using EventStream.
//!
//! ```
//! use std::{
//! io::{stdout, Write},
//! time::Duration,
//! };
//!
//! use aerostream::Client;
//! use anyhow::Result;
//! use chrono::Local;
//!
//! fn main() -> Result<()> {
//! env_logger::init();
//! let mut client = Client::default();
//! client.set_timeout(5);
//! client.connect_ws()?;
//! loop {
//! 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();
//! }
//! std::thread::sleep(Duration::from_millis(10));
//! }
//! }
//! ```
pub use ;
pub use ;
pub use ;