自定义超时回复
This commit is contained in:
		
							parent
							
								
									4e94260843
								
							
						
					
					
						commit
						ccbeafc390
					
				| 
						 | 
					@ -83,16 +83,16 @@ export default class plugin {
 | 
				
			||||||
   * @param type 执行方法
 | 
					   * @param type 执行方法
 | 
				
			||||||
   * @param isGroup 是否群聊
 | 
					   * @param isGroup 是否群聊
 | 
				
			||||||
   * @param time 操作时间,默认120秒
 | 
					   * @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)
 | 
					    const key = this.conKey(isGroup)
 | 
				
			||||||
    if (!stateArr[key]) stateArr[key] = {}
 | 
					    if (!stateArr[key]) stateArr[key] = {}
 | 
				
			||||||
    stateArr[key][type] = this.e
 | 
					    stateArr[key][type] = this.e
 | 
				
			||||||
    if (time) stateArr[key][type].timeout = setTimeout(() => {
 | 
					    if (time) stateArr[key][type].timeout = setTimeout(() => {
 | 
				
			||||||
      if (stateArr[key][type]) {
 | 
					      if (stateArr[key][type]) {
 | 
				
			||||||
        delete stateArr[key][type]
 | 
					        delete stateArr[key][type]
 | 
				
			||||||
        silent || this.reply("操作超时已取消", true)
 | 
					        this.reply(reply, true)
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }, time * 1000)
 | 
					    }, time * 1000)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue