Giter Club home page Giter Club logo

atri_bot's Introduction

AtriBot

Atri

QQ群怎能少得了高性能亚托莉的身影呢?

本项目致力于快速部署,简单使用。

项目Logo由妮娅ko绘制

声明

本项目仅供学习参考,请勿用于非法或商业用途。

本项目形象均来自《Atri-MyDearMoments

特性

  • 使用Rust及ricq构建

Rust: 一门赋予每个人的构建可靠且高效软件能力的语言。

ricq: 使用Rust编写的qq协议

  • 支持加载原生动态库插件, 高性能低占用

部署

使用登陆帮助程序atri_login登陆后得到devicetoken, 放入clients文件夹内,然后配置登陆信息(位于service/login.toml)即可

TODO

  • 完善事件
  • 完善消息类型
  • 完善插件管理

本Bot遵循AtriPlugin原生插件加载标准, 若要使用Rust编写插件, AtriPlugin项目提供了友好的接口, 可以快速上手: 插件开发文档

若需要使用其他的Native语言编写插件, 请参阅: 插件加载方式

二次开发

可直接基于本项目进行二次开发, 而不是作为插件加载

配置 Cargo.toml:

[dependencies]
atri_bot = "0.4.0"

注意

目前处于开发阶段, 不保证插件接口稳定. 更推荐直接基于本项目进行二次开发

*在0.2版本(及以后), 插件提供一定程度的跨版本兼容。

atri_bot's People

Contributors

dependabot[bot] avatar goodjooy avatar laolittle avatar nkdark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

atri_bot's Issues

优化使用引用计数器数据的ffi传输

AtriBot内有很多Arc wrapper, 比如Client, Group, Friend...

他们的数据转移到插件的时候会先转换为Managed结构体
该转换包含了一次堆分配, 而Arc本身就是将数据存入堆中的(也就是变成了Box<Arc>)

考虑添加ManagedArc, 使用Arc::into_rawArc::from_raw, 减少堆分配(释放)

FFIMessageValue不稳定

如果拓展了消息类型,那么很可能会导致访问出现问题,考虑存放到堆转换为指针并保存原始FFIMessageValue,插件未能匹配则直接保存指针

armv7-unknown-linux-musleabihf 插件加载失败

使用 atri_qq-armv7-unknown-linux-musleabihf 无法加载插件,可能是 musl 不支持加载动态库(也可能是不可以跨架构加载?)。

2022-09-28 15:25:23  INFO 正在加载插件: libatri_plugin_hi.so
2022-09-28 15:25:23 ERROR 插件(libatri_plugin_hi.so)加载失败: PluginLoadError("无法加载插件动态库: Dynamic loading not supported")

我自己打包的 armhf 可以加载。

而且,musl 平台不能编译 dylib。

/root/projects/atri_plugin_hi〉cargo build --release --verbose --verbose --jobs 4 --target armv7-unknown-linux-musleabihf
error: cannot produce cdylib for `atri_plugin_hi v0.1.0 (/root/projects/atri_plugin_hi)` as the target `armv7-unknown-linux-musleabihf` does not support these crate types
/root/atri〉file atri_bot
atri_bot: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=95597a151fa619c31b605c6c56d68648689c8868, for GNU/Linux 3.2.0, stripped
/root/atri〉file atri_qq-armv7-unknown-linux-musleabihf
atri_qq-armv7-unknown-linux-musleabihf: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, stripped
/root/atri〉file plugins/libatri_plugin_hi.so
plugins/libatri_plugin_hi.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=a0cdee72846e103fba32964cb66ae34a87ba104f, with debug_info, not stripped

指令系统设想

指令系统

单指令

单个可以执行的指令

#[command(name = "x", help="a")]
async fn a(arg1: ..) -> Result<(), ?> {

}

调用方式: /x arg1..

复合指令

#[command(name = "x")]
mod a {
  #[command(name = "y")]
  fn b() {}
  
  #[command(name = "z")]
  mod c {}
}

调用方式: /x y or /x z ...

指令执行器

所有的指令应先注册到执行器
然后由执行器统一执行

指令参数分析器

参数与参数间应有空格
将消息隔开并迭代, 尝试将字符串一个个解析为对应的参数
失败则不执行此指令

定义trait CommandArg, 要求参数实现CommandArg

宏生成后的代码类似:

let mut iter = cmd.split(' ');
a(
  <A as CommandArg>::from_str(iter.next()?)?,
  <B as CommandArg>::from_str(iter.next()?)?,
  <C as CommandArg>::from_str(iter.next()?)?,
).await

对于同步函数,应额外加上block_in_place

FFI

暴露指令注册函数
函数应为同步函数或异步函数(返回FFIFuture)

union CommandUnion {
  fun: extern "C" fn(..),
  async_fun: extern "C" fn(..) -> FFIFuture,
  set: RustVec<FFICommand>,
}

struct FFICommand {
  name: RustStr,
  type: u8, // 0: sync, 1: async, 2: complex
  inner: CommandUnion
}

程序直接崩溃

在该日志打印完毕后程序直接崩溃

=======================================
欢迎使用AtriBot
本项目基于`MPL2.0`协议开源
你可以在Github找到本项目的源码:

https://github.com/LaoLittle/atri_bot

当前版本: 0.8.2
=======================================

�[2m2023-01-15 11:52:42�[0m �[32m INFO�[0m 已加载0个插件
2023-01-15 11:52:42  INFO 已启动AtriBot

执行文件: atri_bot-x86_64-pc-windows-msvc.exe
操作系统: Windows10
附件:
log.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.