Skip to content

Commit

Permalink
新增命令【脚本输出-增加ID】
Browse files Browse the repository at this point in the history
  • Loading branch information
super1207 committed Dec 21, 2024
1 parent 73eb05a commit 66711b8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/detailref/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,17 @@ onebot事件json对应的RedLang对象。
返回与<font color="red">消息ID</font>有关的当前包的脚本发送的消息的消息ID数组(因内存条很贵,所以最多得到 5分钟以内的数据)。


### 脚本输出-增加ID

【脚本输出-增加ID@<font color="red">消息ID</font>】

给当前消息添加相关的<font color="red">消息ID</font>。

专门用于【OB调用】之后手动添加消息ID。

**注意**:这是一个实验性质的较底层的命令,用法很有可能会在之后的版本中发生变化(可能删除)


### 积分

【积分】
Expand Down
24 changes: 24 additions & 0 deletions src/redlang/cqexfun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,30 @@ pub fn init_cq_ex_fun_map() {
return Ok(Some(self_t.build_arr(ret_vec)));
}
});

add_fun(vec!["脚本输出-增加ID"],|self_t,params|{
let src_msg_id = self_t.get_exmap("消息ID"); // self_t.get_param(params, 0)?;
let to_add_msg_id = self_t.get_param(params, 0)?;
let self_id = self_t.get_exmap("机器人ID");
let key = format!("{}|{}|{}",self_t.pkg_name,self_id,src_msg_id);
let mut lk = G_SCRIPT_RELATE_MSG.write()?;
let val_opt = lk.get_mut(&key);
if val_opt.is_none() {
let tm = SystemTime::now().duration_since(std::time::UNIX_EPOCH)?.as_secs();
lk.insert(key, ScriptRelatMsg{
self_id:(*self_id).to_owned(),
msg_id_vec:[to_add_msg_id].to_vec(),
create_time:tm
});
return Ok(Some("".to_owned()));
}else{
let val = val_opt.unwrap();
val.msg_id_vec.push(to_add_msg_id);
return Ok(Some("".to_owned()));
}
});


add_fun(vec!["积分-增加"],|self_t,params|{
let key1 = self_t.get_exmap("群ID");
let group_id = format!("{}",key1);
Expand Down

0 comments on commit 66711b8

Please sign in to comment.