41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package autoReply -----------------------------
 | |
| // @file      : rulerList.go
 | |
| // @author    : JJXu
 | |
| // @contact   : wavingbear@163.com
 | |
| // @time      : 2025/6/13 16:16
 | |
| // -------------------------------------------
 | |
| package robot
 | |
| 
 | |
| import (
 | |
| 	"fonchain-fiee/pkg/service/asChat/dto"
 | |
| 	"strings"
 | |
| )
 | |
| 
 | |
| // 自动回复规则结构转换
 | |
| func ParseReplyRule(data *dto.ChatAutoReplyData) (r Reply) {
 | |
| 	r.Response = data.Response
 | |
| 	for ruleName, v := range data.Rules {
 | |
| 		if !v.Enable {
 | |
| 			continue
 | |
| 		}
 | |
| 		switch ruleName {
 | |
| 		case "keywords": //关键字回复
 | |
| 			var keywords []string
 | |
| 			if v.Content == "" {
 | |
| 				continue
 | |
| 			} else {
 | |
| 				keywords = strings.Split(v.Content, ",")
 | |
| 			}
 | |
| 			r.Rules = append(r.Rules, NewReplyWhenHitKeywords(keywords))
 | |
| 		case "joinSession": //加入聊天后回复
 | |
| 			r.Rules = append(r.Rules, NewReplyWhenUserJoinSession())
 | |
| 		case "noReplyAfter": //指定时间没有回复则自动回复
 | |
| 			if v.SecondDuration == 0 {
 | |
| 				continue
 | |
| 			}
 | |
| 			r.Rules = append(r.Rules, NewReplyWhenWaiterNoAction(v.SecondDuration))
 | |
| 		}
 | |
| 	}
 | |
| 	return
 | |
| }
 |