fishpi-sdk 0.1.4

A Rust SDK for interacting with the FishPi community API
Documentation

FishPi Rust SDK

Crates.io Documentation License: MIT

一个用于与摸鱼派社区 API 交互的 Rust SDK,提供用户管理、文章、聊天室、私聊、通知、清风明月、红包、评论、举报、日志、文件上传等功能的异步客户端。

安装

Cargo.toml 中添加:

[dependencies]

fishpi-sdk = "0.1.4"

tokio = { version = "1", features = ["full"] }

或使用 Cargo:

cargo add fishpi-sdk

快速开始

use fishpi_sdk::{FishPi, api::chatroom::ChatRoom};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 创建聊天室客户端
    let mut chatroom = ChatRoom::new("your_api_key".to_string());

    // 监听消息事件(直接传递具体类型,无需 match)
    chatroom.on_msg(|msg| {
        println!("Message: {}", msg.content);
    }).await;

    // 监听弹幕事件
    chatroom.on_barrager(|barrager| {
        println!("Barrage: {}", barrager.content);
    }).await;

    // 连接聊天室
    chatroom.connect(false).await?;

    // 发送消息
    chatroom.send("Hello!".to_string()).await?;

    Ok(())
}

功能

  • 用户管理:登录、注册、获取用户信息、修改资料
  • 内容操作:文章、评论、清风明月
  • 聊天:聊天室、私聊
  • 其他:通知、红包、举报、日志、文件上传

API 文档

完整文档请查看 docs.rs

贡献

欢迎提交 Issue 和 Pull Request。请确保代码通过 cargo testcargo clippy

许可证

本项目采用 MIT 许可证