| Crates.io | puniyu_bot |
| lib.rs | puniyu_bot |
| version | 0.4.1 |
| created_at | 2025-10-24 15:33:41.080018+00 |
| updated_at | 2025-11-16 07:32:05.548727+00 |
| description | puniyu 的bot相关 |
| homepage | https://github.com/puniyu/puniyu |
| repository | https://github.com/puniyu/puniyu |
| max_upload_size | |
| id | 1898603 |
| size | 82,294 |
puniyu 的bot相关管理模块,提供Bot实例的注册、查找和卸载功能。
该 crate 提供了Bot实例的生命周期管理功能,包括:
表示一个Bot实例,包含以下字段:
index: Bot的唯一索引adapter: 适配器信息(AdapterInfo)account: 账号信息(AccountInfo)Bot标识符枚举,支持两种方式:
Index(u64): 通过索引标识BotSelfId(String): 通过self_id标识BotBot注册表,提供以下静态方法:
get_all(): 获取所有已注册的Bot实例get_with_index(index: u64): 根据索引获取Bot实例get_with_self_id(self_id: &str): 根据self_id获取Bot实例register(adapter: AdapterInfo, account: AccountInfo): 注册新的Bot实例unregister(index: u64): 根据索引卸载Bot实例unregister_with_id(id: &str): 根据self_id卸载Bot实例用于注册Bot实例的宏,支持两种语法:
register_bot!(adapter_info, account_info);
register_bot!(adapter: adapter_info, account: account_info);
用于卸载Bot实例的宏,支持三种语法:
unregister_bot!("self_id");
unregister_bot!(index: 1);
unregister_bot!(id: "self_id");
该模块主要用于管理多个Bot实例的生命周期,适用于需要同时运行多个Bot的场景。通过全局注册表,可以在系统的任何地方方便地访问已注册的Bot实例。
本项目采用 LGPL 许可证。