#事件流 #蓝空 #过滤器 #操作 #客户端

bin+lib 气流

气流是使用事件流的蓝空客户端。

46 个版本 (14 个破坏性版本)

0.16.5 2024 年 5 月 23 日
0.16.0 2024 年 4 月 28 日
0.15.1 2024 年 3 月 27 日
0.14.1 2023 年 12 月 26 日
0.6.3 2023 年 7 月 28 日

#6 in #蓝空

Download history 14/week @ 2024-04-18 159/week @ 2024-04-25 10/week @ 2024-05-02 194/week @ 2024-05-09 25/week @ 2024-05-16 523/week @ 2024-05-23 9/week @ 2024-05-30 23/week @ 2024-06-06 10/week @ 2024-06-13 225/week @ 2024-07-04 40/week @ 2024-07-11

每月 72 次下载

Apache-2.0

345KB
9K SLoC

气流

气流是使用事件流的蓝空客户端。

它可以作为一个库或命令行工具使用。

作为命令行工具使用

cargo install aerostream -F terminal
aerostream

注意

  • 仅限命令行界面,无需登录。
  • 因此,您不能发布、重新发布和点赞。
  • 配置文件必须使用文本编辑器进行编辑,应用程序中没有配置界面。

编辑 filters.yaml

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>

操作

  • q 或 Ctrl+c : 退出此应用程序
  • F5 或 Ctrl+r : 重新绘制屏幕
  • s : 订阅 "收藏" 过滤器中关注的帖子的存储库
  • u : 取消订阅 "收藏" 过滤器中关注的帖子的存储库
  • LEFT 或 RIGHT : 切换关注的过滤器
  • UP 或 DOWN : 切换关注的帖子
  • ESC : 将焦点从帖子移开
  • i : 查看附件图片
  • j : 查看下一张附件图片
  • k : 查看上一张附件图片
  • Backspace : 离开图片查看
  • Enter : 在默认浏览器中打开 bsky.app,使用当前帖子或图片

作为库使用

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(())
}

依赖关系

~10–25MB
~382K SLoC