Compare commits

..

No commits in common. "d2eefbb646c732988535deaac2b91d6bc5b3077a" and "a093585416c51d5c23bb91d4894901bd4126dd03" have entirely different histories.

3 changed files with 12 additions and 18 deletions

View File

@ -168,8 +168,8 @@ func (r *Robot) Run() {
hit := false
for _, rule := range r.joinSessionRules {
hit = rule.Hit(event, r.Info)
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
if hit {
fmt.Println("命中规则:", rule.GetTitle())
if rule.RunTime().IsZero() {
err := rule.Run(r.cache)
if err != nil {
@ -183,7 +183,6 @@ func (r *Robot) Run() {
if !hit {
for _, rule := range r.keywordsRules {
hit = rule.Hit(event, r.Info)
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
if hit {
fmt.Println("命中规则:", rule.GetTitle())
if rule.RunTime().IsZero() {
@ -199,8 +198,7 @@ func (r *Robot) Run() {
}
if !hit {
for _, rule := range r.noReplyAfterRules {
hit = rule.Hit(event, r.Info)
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
hit := rule.Hit(event, r.Info)
if hit {
fmt.Println("命中规则:", rule.GetTitle())
if rule.RunTime().IsZero() {

View File

@ -8,24 +8,10 @@ package robot
import (
"fmt"
"fonchain-fiee/api/accountFiee"
"fonchain-fiee/pkg/common/ws"
"fonchain-fiee/pkg/service/asChat/chatCache"
"fonchain-fiee/pkg/service/asChat/dto"
"strings"
"time"
)
type IRobotTask interface {
Hit(event ws.ListenEventData, sender *accountFiee.ChatUserData) (hit bool)
Run(cache *chatCache.ChatCache) error
RunTime() time.Time
SetResponse(response string)
GetResponse() string
SetTitle(title string)
GetTitle() string
}
// 自动回复规则结构转换
func ParseReplyRule(data []*dto.ChatAutoReplyData) (joinSessionRules, keywordsRules, noReplyAfterRules []IRobotTask) {
for _, responseRules := range data {

View File

@ -18,6 +18,16 @@ import (
"time"
)
type IRobotTask interface {
Hit(event ws.ListenEventData, sender *accountFiee.ChatUserData) (hit bool)
Run(cache *chatCache.ChatCache) error
RunTime() time.Time
SetResponse(response string)
GetResponse() string
SetTitle(title string)
GetTitle() string
}
// 客服指定时间不回复则自动回复
func NewReplyWhenWaiterNoAction(title string, delaySecond time.Duration) IRobotTask {
return &RobotTaskReplyWhenWaiterNoAction{