Merge branch 'chat' into dev
This commit is contained in:
commit
4afa15ee3f
@ -168,8 +168,8 @@ func (r *Robot) Run() {
|
|||||||
hit := false
|
hit := false
|
||||||
for _, rule := range r.joinSessionRules {
|
for _, rule := range r.joinSessionRules {
|
||||||
hit = rule.Hit(event, r.Info)
|
hit = rule.Hit(event, r.Info)
|
||||||
|
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
|
||||||
if hit {
|
if hit {
|
||||||
fmt.Println("命中规则:", rule.GetTitle())
|
|
||||||
if rule.RunTime().IsZero() {
|
if rule.RunTime().IsZero() {
|
||||||
err := rule.Run(r.cache)
|
err := rule.Run(r.cache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -183,6 +183,7 @@ func (r *Robot) Run() {
|
|||||||
if !hit {
|
if !hit {
|
||||||
for _, rule := range r.keywordsRules {
|
for _, rule := range r.keywordsRules {
|
||||||
hit = rule.Hit(event, r.Info)
|
hit = rule.Hit(event, r.Info)
|
||||||
|
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
|
||||||
if hit {
|
if hit {
|
||||||
fmt.Println("命中规则:", rule.GetTitle())
|
fmt.Println("命中规则:", rule.GetTitle())
|
||||||
if rule.RunTime().IsZero() {
|
if rule.RunTime().IsZero() {
|
||||||
@ -198,7 +199,8 @@ func (r *Robot) Run() {
|
|||||||
}
|
}
|
||||||
if !hit {
|
if !hit {
|
||||||
for _, rule := range r.noReplyAfterRules {
|
for _, rule := range r.noReplyAfterRules {
|
||||||
hit := rule.Hit(event, r.Info)
|
hit = rule.Hit(event, r.Info)
|
||||||
|
fmt.Printf("规则【%s】校验结果:%v\n", rule.GetTitle(), hit)
|
||||||
if hit {
|
if hit {
|
||||||
fmt.Println("命中规则:", rule.GetTitle())
|
fmt.Println("命中规则:", rule.GetTitle())
|
||||||
if rule.RunTime().IsZero() {
|
if rule.RunTime().IsZero() {
|
||||||
|
@ -8,10 +8,24 @@ package robot
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"fonchain-fiee/api/accountFiee"
|
||||||
|
"fonchain-fiee/pkg/common/ws"
|
||||||
|
"fonchain-fiee/pkg/service/asChat/chatCache"
|
||||||
"fonchain-fiee/pkg/service/asChat/dto"
|
"fonchain-fiee/pkg/service/asChat/dto"
|
||||||
"strings"
|
"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) {
|
func ParseReplyRule(data []*dto.ChatAutoReplyData) (joinSessionRules, keywordsRules, noReplyAfterRules []IRobotTask) {
|
||||||
for _, responseRules := range data {
|
for _, responseRules := range data {
|
||||||
|
@ -18,16 +18,6 @@ import (
|
|||||||
"time"
|
"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 {
|
func NewReplyWhenWaiterNoAction(title string, delaySecond time.Duration) IRobotTask {
|
||||||
return &RobotTaskReplyWhenWaiterNoAction{
|
return &RobotTaskReplyWhenWaiterNoAction{
|
||||||
|
Loading…
Reference in New Issue
Block a user