自定义超时回复

This commit is contained in:
UCPr 2024-03-26 13:47:35 +08:00
parent 4e94260843
commit ccbeafc390
1 changed files with 3 additions and 3 deletions

View File

@ -83,16 +83,16 @@ export default class plugin {
* @param type 执行方法
* @param isGroup 是否群聊
* @param time 操作时间默认120秒
* @param {boolean} [silent=false] 是否静默超时不回复消息
* @param reply 超时时回复的内容false则不回复
*/
setContext(type, isGroup, time = 120, silent = false) {
setContext(type, isGroup, time = 120, reply = "操作超时已取消") {
const key = this.conKey(isGroup)
if (!stateArr[key]) stateArr[key] = {}
stateArr[key][type] = this.e
if (time) stateArr[key][type].timeout = setTimeout(() => {
if (stateArr[key][type]) {
delete stateArr[key][type]
silent || this.reply("操作超时已取消", true)
this.reply(reply, true)
}
}, time * 1000)
}