laolittle / atri_bot Goto Github PK
View Code? Open in Web Editor NEWA simple bot in rust running on various platforms
Home Page: https://AtriKawaii.github.io/atri_doc/
License: Mozilla Public License 2.0
A simple bot in rust running on various platforms
Home Page: https://AtriKawaii.github.io/atri_doc/
License: Mozilla Public License 2.0
使用 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
rust-toolchain: nightly-1.67
platform: ubuntu-latest
/usr/local/lib/gcc/x86_64-unknown-freebsd12/6.4.0/../../../../x86_64-unknown-freebsd12/bin/ld: cannot find -lmemstat
error: could not compile `atri_bot` due to previous error
action: https://github.com/LaoLittle/atri_bot/actions/runs/3655621870/jobs/6177222024
https://github.com/bminor/musl/blob/master/src/ldso/dlopen.c
musl使用dlopen会直接error
请看: #5
考虑使用其他的动态链接器
活久见, 我在mac上可以正常拦截事件, 放到服务器就没拦住
暂时不知道问题在哪
AtriBot
内有很多Arc wrapper, 比如Client
, Group
, Friend
...
他们的数据转移到插件的时候会先转换为Managed
结构体
该转换包含了一次堆分配, 而Arc
本身就是将数据存入堆中的(也就是变成了Box<Arc>)
考虑添加ManagedArc
, 使用Arc::into_raw
与Arc::from_raw
, 减少堆分配(释放)
如果拓展了消息类型,那么很可能会导致访问出现问题,考虑存放到堆转换为指针并保存原始FFIMessageValue,插件未能匹配则直接保存指针
单个可以执行的指令
#[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
暴露指令注册函数
函数应为同步函数或异步函数(返回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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.