| Crates.io | cqtool |
| lib.rs | cqtool |
| version | 0.1.0 |
| created_at | 2025-03-05 11:44:53.91999+00 |
| updated_at | 2025-03-05 11:44:53.91999+00 |
| description | A tool for converting between CQ strings and message segment arrays |
| homepage | |
| repository | https://github.com/super1207/cqtool-rs |
| max_upload_size | |
| id | 1578891 |
| size | 13,544 |
可以完成CQ字符串与消息段数组之间的互相转换
cargo add cqtool
let cqstr = "你好[CQ:at,qq=123456]";
let cqjson:serde_json::Value = cqtool::to_arr_msg(cqstr).unwrap();
println!("{}",serde_json::to_string_pretty(&cqjson).unwrap());
输出:
[
{
"data": {
"text": "你好"
},
"type": "text"
},
{
"data": {
"qq": "123456"
},
"type": "at"
}
]
let json_arr:serde_json::Value = serde_json::json!([{"data": {"text": "你好"},"type": "text"},{"data": {"qq": "123456"},"type": "at"}]);
let cqstr = cqtool::to_str_msg(&json_arr).unwrap();
println!("{}", cqstr);
输出:
你好[CQ:at,qq=123456]
let cqstr = format!("你好[CQ:at,qq={}]",cqtool::cq_params_encode("123456"));
println!("{}",cqstr);
输出:
你好[CQ:at,qq=123456]
let cqstr = format!("{}[CQ:at,qq=123456]",cqtool::cq_text_encode("你好"));
println!("{}",cqstr);
输出:
你好[CQ:at,qq=123456]