diff --git a/pkg/common/ws/chatRoom.go b/pkg/common/ws/chatRoom.go
index fbaf602..419324f 100644
--- a/pkg/common/ws/chatRoom.go
+++ b/pkg/common/ws/chatRoom.go
@@ -216,7 +216,7 @@ func (o *ChatRoom) SendSessionMessage(chatUser *accountFiee.ChatUserData, sessio
 			}
 		}
 		fmt.Printf("client:%+v\n", client)
-		if client != nil && client.UserId != chatUser.ID {
+		if client != nil && (client.UserId != chatUser.ID || chatUser.Role == 3) {
 			client.Send <- msgBytes
 			go o.pushEvent(EventChatMessage, EventProgressAfter, chatUser, o.Session[sessionId][i], message)
 			userIdInSession = append(userIdInSession, client.UserId)
diff --git a/pkg/service/asChat/dto/dto.go b/pkg/service/asChat/dto/dto.go
index 3bfc202..5f38565 100644
--- a/pkg/service/asChat/dto/dto.go
+++ b/pkg/service/asChat/dto/dto.go
@@ -81,7 +81,7 @@ func (m *MessageListType) BuildMessage(data *accountFiee.ChatRecordData) {
 				})
 			}
 		}
-	case accountFiee.MsgType_TextMsgType, accountFiee.MsgType_CardType:
+	case accountFiee.MsgType_TextMsgType:
 		m.Message = Message{
 			MsgType:    data.MsgType,
 			Text:       data.Content,
diff --git a/pkg/service/asChat/handler.go b/pkg/service/asChat/handler.go
index b5a42f6..7260b25 100644
--- a/pkg/service/asChat/handler.go
+++ b/pkg/service/asChat/handler.go
@@ -42,9 +42,14 @@ import (
 	"go.uber.org/zap"
 )
 
-var ChatHandlerIns = ChatHandler{
-	cache: chatCache.ChatCache{NewMessageStatExpireAfter: 10 * time.Minute},
-	robot: robot.NewRobot(),
+var ChatHandlerIns = NewChatHandler()
+
+func NewChatHandler() ChatHandler {
+	c := ChatHandler{
+		cache: chatCache.ChatCache{NewMessageStatExpireAfter: 10 * time.Minute},
+	}
+	c.robot = robot.NewRobot(&c.cache)
+	return c
 }
 
 type ChatHandler struct {
diff --git a/pkg/service/asChat/robot/replyAndRuler.go b/pkg/service/asChat/robot/replyAndRuler.go
index 8afe6e5..d731297 100644
--- a/pkg/service/asChat/robot/replyAndRuler.go
+++ b/pkg/service/asChat/robot/replyAndRuler.go
@@ -8,12 +8,12 @@ package robot
 
 import (
 	"context"
-	"fmt"
 	"fonchain-fiee/api/accountFiee"
 	"fonchain-fiee/pkg/common/ws"
 	"fonchain-fiee/pkg/service"
-	"fonchain-fiee/pkg/service/asChat/consts"
+	"fonchain-fiee/pkg/service/asChat/chatCache"
 	"fonchain-fiee/pkg/service/asChat/dto"
+	"fonchain-fiee/pkg/service/asChat/logic"
 	"strings"
 	"time"
 )
@@ -24,9 +24,9 @@ type Reply struct {
 	Rules    []IRule
 }
 
-func (r *Reply) Hit(eventType ws.EventType, chatUser *accountFiee.ChatUserData, wsClient *ws.Client, msg string, robotInfo *accountFiee.ChatUserData) (hit bool, runTime time.Time, logic func(msg string) error) {
+func (r *Reply) Hit(event ws.ListenEventData, robotInfo *accountFiee.ChatUserData) (hit bool, task RobotTask) {
 	for _, rule := range r.Rules {
-		hit, runTime, logic = rule.Hit(eventType, chatUser, wsClient, msg, robotInfo)
+		hit, task = rule.Hit(event, robotInfo)
 		if hit {
 			return
 		}
@@ -36,11 +36,7 @@ func (r *Reply) Hit(eventType ws.EventType, chatUser *accountFiee.ChatUserData,
 
 // 规则接口
 type IRule interface {
-	Hit(eventType ws.EventType, chatUser *accountFiee.ChatUserData, wsClient *ws.Client, msg string, robotInfo *accountFiee.ChatUserData) (hit bool, runTime time.Time, logic func(msg string) error)
-}
-
-func NewReplyWhenHitKeywords(keywords []string) IRule {
-	return &ReplyWhenHitKeywords{Keywords: keywords}
+	Hit(event ws.ListenEventData, robotInfo *accountFiee.ChatUserData) (hit bool, task RobotTask)
 }
 
 // KeywordsRuleChecker 关键字回复
@@ -48,53 +44,80 @@ type ReplyWhenHitKeywords struct {
 	Keywords []string `json:"keywords"`
 }
 
-func (k ReplyWhenHitKeywords) Hit(eventType ws.EventType, chatUser *accountFiee.ChatUserData, wsClient *ws.Client, msg string, robotInfo *accountFiee.ChatUserData) (hit bool, runTime time.Time, logic func(msg string) error) {
-	if eventType != ws.EventChatMessage || msg == "" || wsClient == nil || chatUser == nil {
+func NewReplyWhenHitKeywords(keywords []string) IRule {
+	return &ReplyWhenHitKeywords{Keywords: keywords}
+}
+func (k ReplyWhenHitKeywords) Hit(event ws.ListenEventData, robotInfo *accountFiee.ChatUserData) (hit bool, task RobotTask) {
+	if event.EventType != ws.EventChatMessage || event.Msg == "" || event.Client == nil || event.ChatUser == nil {
 		return
 	}
 
 	for _, v := range k.Keywords {
-		if strings.Contains(msg, v) {
+		if strings.Contains(event.Msg, v) {
 			hit = true
 			break
 		}
 	}
-	logic = func(content string) error {
-		var notice = dto.MessageListType{}
-		newRecord := &accountFiee.ChatRecordData{
-			SessionId: wsClient.SessionId,
-			UserId:    wsClient.UserId,
-			Name:      chatUser.NickName,
-			Avatar:    robotInfo.Avatar,
-			MsgType:   1,
-			Content:   content,
-		}
-		notice.BuildMessage(newRecord)
-		_, err := consts.ChatRoom.SendSessionMessage(robotInfo, wsClient.SessionId, ws.NewChatMsgType, notice)
-		return err
+	task = RobotTask{
+		ChatUser: event.ChatUser,
+		Run: func(msg string, cache *chatCache.ChatCache, Sender *accountFiee.ChatUserData) error {
+			return logic.NewMessage(context.Background(), cache, Sender, dto.NewMessageRequest{
+				Waiter:    true,
+				SessionId: event.Client.SessionId,
+				Message: dto.Message{
+					MsgType:    1,
+					Text:       msg,
+					LocalStamp: time.Now().Unix(),
+				},
+			})
+		},
 	}
+	//logicFunc = func(content string, cache *chatCache.ChatCache, chatUser *accountFiee.ChatUserData) error {
+	//	//var notice = dto.MessageListType{}
+	//	//newRecord := &accountFiee.ChatRecordData{
+	//	//	SessionId: wsClient.SessionId,
+	//	//	UserId:    wsClient.UserId,
+	//	//	Name:      chatUser.NickName,
+	//	//	Avatar:    robotInfo.Avatar,
+	//	//	MsgType:   1,
+	//	//	Content:   content,
+	//	//}
+	//	//notice.BuildMessage(newRecord)
+	//	//_, err := consts.ChatRoom.SendSessionMessage(robotInfo, wsClient.SessionId, ws.NewChatMsgType, notice)
+	//	//return err
+	//	err := logic.NewMessage(context.Background(), cache, chatUser, dto.NewMessageRequest{
+	//		Waiter:    true,
+	//		SessionId: wsClient.SessionId,
+	//		Message: dto.Message{
+	//			MsgType:    1,
+	//			Text:       msg,
+	//			LocalStamp: time.Now().Unix(),
+	//		},
+	//	})
+	//	return err
+	//}
 	return
 }
 
 // 用户打开聊天会话直接发送
+type ReplyWhenUserJoinSession struct {
+}
+
 func NewReplyWhenUserJoinSession() IRule {
 	return &ReplyWhenUserJoinSession{}
 }
 
-type ReplyWhenUserJoinSession struct {
-}
-
-func (k ReplyWhenUserJoinSession) Hit(eventType ws.EventType, chatUser *accountFiee.ChatUserData, wsClient *ws.Client, msg string, robotInfo *accountFiee.ChatUserData) (hit bool, runTime time.Time, logic func(msg string) error) {
-	if eventType != ws.EventUserJoin {
+func (k ReplyWhenUserJoinSession) Hit(event ws.ListenEventData, robotInfo *accountFiee.ChatUserData) (hit bool, task RobotTask) {
+	if event.EventType != ws.EventUserJoin {
 		return
 	}
-	if wsClient == nil {
+	if event.Client == nil {
 		return
 	}
 	ctx := context.Background()
 	queryRes, err := service.AccountFieeProvider.GetChatRecordList(ctx, &accountFiee.GetChatRecordListRequest{
 		Query: &accountFiee.ChatRecordData{
-			SessionId: wsClient.SessionId,
+			SessionId: event.Client.SessionId,
 		},
 		Page:     1,
 		PageSize: 1,
@@ -114,67 +137,115 @@ func (k ReplyWhenUserJoinSession) Hit(eventType ws.EventType, chatUser *accountF
 		}
 	}
 	hit = true
-	logic = func(msg string) error {
-		var notice = dto.MessageListType{}
-		newRecord := &accountFiee.ChatRecordData{
-			SessionId: wsClient.SessionId,
-			UserId:    wsClient.UserId,
-			Name:      wsClient.SessionId,
-			Avatar:    robotInfo.Avatar,
-			MsgType:   1,
-			Content:   msg,
+	if event.ChatUser == nil {
+		event.ChatUser, err = service.AccountFieeProvider.GetChatUserDetail(context.Background(), &accountFiee.GetChatUserByIdRequest{Id: event.Client.UserId})
+		if err != nil {
+			return
 		}
-		notice.BuildMessage(newRecord)
-		_, err = consts.ChatRoom.SendSessionMessage(robotInfo, wsClient.SessionId, ws.NewChatMsgType, notice)
-		return err
 	}
+	task = RobotTask{
+		ChatUser: event.ChatUser,
+		Run: func(msg string, cache *chatCache.ChatCache, Sender *accountFiee.ChatUserData) error {
+			return logic.NewMessage(ctx, cache, Sender, dto.NewMessageRequest{
+				Waiter:    true,
+				SessionId: event.Client.SessionId,
+				Message: dto.Message{
+					MsgType:    1,
+					Text:       msg,
+					LocalStamp: time.Now().Unix(),
+				},
+			})
+		},
+	}
+	//logicFunc = func(msg string, cache *chatCache.ChatCache, chatUser *accountFiee.ChatUserData) error {
+	//	//var notice = dto.MessageListType{}
+	//	//newRecord := &accountFiee.ChatRecordData{
+	//	//	SessionId: wsClient.SessionId,
+	//	//	UserId:    wsClient.UserId,
+	//	//	Name:      wsClient.SessionId,
+	//	//	Avatar:    robotInfo.Avatar,
+	//	//	MsgType:   1,
+	//	//	Content:   msg,
+	//	//}
+	//	//notice.BuildMessage(newRecord)
+	//	//_, err = consts.ChatRoom.SendSessionMessage(robotInfo, wsClient.SessionId, ws.NewChatMsgType, notice)
+	//	err = logic.NewMessage(ctx, cache, chatUser, dto.NewMessageRequest{
+	//		Waiter:    true,
+	//		SessionId: wsClient.SessionId,
+	//		Message: dto.Message{
+	//			MsgType:    1,
+	//			Text:       msg,
+	//			LocalStamp: time.Now().Unix(),
+	//		},
+	//	})
+	//	return err
+	//}
 	return
 }
 
-// 客服
+// 客服指定时间不回复则自动回复
+
+type ReplyWhenWaiterNoAction struct {
+	DelaySecond time.Duration
+}
+
 func NewReplyWhenWaiterNoAction(delaySecond time.Duration) *ReplyWhenWaiterNoAction {
 	return &ReplyWhenWaiterNoAction{
 		DelaySecond: delaySecond,
 	}
 }
 
-type ReplyWhenWaiterNoAction struct {
-	DelaySecond time.Duration
-}
+func (k *ReplyWhenWaiterNoAction) Hit(event ws.ListenEventData, chatUser *accountFiee.ChatUserData) (hit bool, task RobotTask) {
+	if event.Client == nil || event.EventType != ws.EventChatMessage {
+		return
+	}
+	task = RobotTask{
+		RunTime: time.Now().Add(k.DelaySecond * time.Second),
+		Run: func(content string, cache *chatCache.ChatCache, Sender *accountFiee.ChatUserData) error {
+			//如果客服已经回复则不发送消息
+			chatRecordListRes, err := service.AccountFieeProvider.GetChatRecordList(context.Background(), &accountFiee.GetChatRecordListRequest{
+				Query: &accountFiee.ChatRecordData{
+					SessionId: event.Client.SessionId,
+				},
+				Page:     1,
+				PageSize: 1,
+				Order:    "created_at desc",
+			})
+			if err != nil || chatRecordListRes.Total == 0 {
+				return err
+			}
+			checkUserId := chatRecordListRes.List[0].UserId
+			checkChatUser, err := service.AccountFieeProvider.GetChatUserDetail(context.Background(), &accountFiee.GetChatUserByIdRequest{Id: checkUserId})
+			if err != nil || checkChatUser.Role != 1 {
+				return err
+			}
 
-func (k *ReplyWhenWaiterNoAction) Hit(eventType ws.EventType, chatUser *accountFiee.ChatUserData, wsClient *ws.Client, msg string, robotInfo *accountFiee.ChatUserData) (hit bool, runTime time.Time, logic func(msg string) error) {
-	runTime = time.Now().Add(k.DelaySecond * time.Second)
-	logic = func(content string) error {
-		//如果客服已经回复则不发送消息
-		chatRecordListRes, err := service.AccountFieeProvider.GetChatRecordList(context.Background(), &accountFiee.GetChatRecordListRequest{
-			Query: &accountFiee.ChatRecordData{
-				SessionId: fmt.Sprintf("%d", chatUser.ID),
-			},
-			Page:     1,
-			PageSize: 1,
-			Order:    "created_at desc",
-		})
-		if err != nil || chatRecordListRes.Total == 0 {
-			return err
-		}
-		checkUserId := chatRecordListRes.List[0].UserId
-		checkChatUser, err := service.AccountFieeProvider.GetChatUserDetail(context.Background(), &accountFiee.GetChatUserByIdRequest{Id: checkUserId})
-		if err != nil || checkChatUser.Role != 1 {
-			return err
-		}
+			//var notice = dto.MessageListType{}
+			//newRecord := &accountFiee.ChatRecordData{
+			//	SessionId: wsClient.SessionId,
+			//	UserId:    wsClient.UserId,
+			//	Name:      chatUser.NickName,
+			//	Avatar:    robotInfo.Avatar,
+			//	MsgType:   1,
+			//	Content:   content,
+			//}
+			//notice.BuildMessage(newRecord)
+			//_, err = consts.ChatRoom.SendSessionMessage(robotInfo, wsClient.SessionId, ws.NewChatMsgType, notice)
+			//return err
 
-		var notice = dto.MessageListType{}
-		newRecord := &accountFiee.ChatRecordData{
-			SessionId: wsClient.SessionId,
-			UserId:    wsClient.UserId,
-			Name:      chatUser.NickName,
-			Avatar:    robotInfo.Avatar,
-			MsgType:   1,
-			Content:   content,
-		}
-		notice.BuildMessage(newRecord)
-		_, err = consts.ChatRoom.SendSessionMessage(robotInfo, wsClient.SessionId, ws.NewChatMsgType, notice)
-		return err
+			err = logic.NewMessage(context.Background(), cache, chatUser, dto.NewMessageRequest{
+				Waiter:    true,
+				SessionId: event.Client.SessionId,
+				Message: dto.Message{
+					MsgType:    1,
+					Text:       event.Msg,
+					LocalStamp: time.Now().Unix(),
+				},
+			})
+			return err
+		},
+		Response: "",
+		ChatUser: event.ChatUser,
 	}
 	return
 
diff --git a/pkg/service/asChat/robot/robot.go b/pkg/service/asChat/robot/robot.go
index 0efcd6f..0ae4759 100644
--- a/pkg/service/asChat/robot/robot.go
+++ b/pkg/service/asChat/robot/robot.go
@@ -12,6 +12,7 @@ import (
 	"fonchain-fiee/api/accountFiee"
 	"fonchain-fiee/pkg/common/ws"
 	"fonchain-fiee/pkg/service"
+	"fonchain-fiee/pkg/service/asChat/chatCache"
 	"fonchain-fiee/pkg/service/asChat/consts"
 	"fonchain-fiee/pkg/service/asChat/dto"
 	"log"
@@ -19,7 +20,7 @@ import (
 	"time"
 )
 
-func NewRobot() *Robot {
+func NewRobot(cache *chatCache.ChatCache) *Robot {
 	ctx := context.Background()
 	robotQuery, err := service.AccountFieeProvider.GetChatUserList(ctx, &accountFiee.GetChatUserListRequest{
 		Query: &accountFiee.ChatUserData{Role: 3},
@@ -53,6 +54,7 @@ func NewRobot() *Robot {
 			},
 			Chan: make(ws.ListenEventChan),
 		},
+		cache: cache,
 	}
 	ruleListRes, err := service.AccountFieeProvider.GetChatAutoReplyRulerList(ctx, &accountFiee.GetChatAutoReplyRulerListRequest{
 		Query:    &accountFiee.ChatAutoReplyRulerData{Status: 1},
@@ -87,6 +89,7 @@ type Robot struct {
 	isRunning bool                      //运行状态
 	mu        sync.Mutex
 	*ws.EventListener
+	cache *chatCache.ChatCache
 }
 
 //func (r *Robot) Listen(record *accountFiee.ChatRecordData) {
@@ -159,7 +162,7 @@ func (r *Robot) Run() {
 				if now.After(task.RunTime) {
 					// 执行任务
 					go func() {
-						err := task.Run(task.Response)
+						err := task.Run(task.Response, r.cache, task.ChatUser)
 						if err != nil {
 							log.Printf("聊天机器人[%d]回复消息失败:%v", r.Info.ID, err)
 						}
@@ -176,19 +179,16 @@ func (r *Robot) Run() {
 		case event := <-r.EventListener.Chan:
 			fmt.Printf("robot listen event:%#v\n", event)
 			for _, ruleResponse := range r.Rules {
-				hit, runtime, logic := ruleResponse.Hit(event.EventType, event.ChatUser, event.Client, event.Msg, r.Info)
+				hit, task := ruleResponse.Hit(event, r.Info)
 				if hit {
-					if runtime.IsZero() {
-						err := logic(ruleResponse.Response)
+					if task.RunTime.IsZero() {
+						err := task.Run(ruleResponse.Response, r.cache, r.Info)
 						if err != nil {
 							log.Printf("robot 执行任务失败:%v\n", err)
 						}
 					} else {
-						r.RegisterDelayTask(RobotTask{
-							RunTime:  runtime,
-							Run:      logic,
-							Response: ruleResponse.Response,
-						})
+						task.Response = ruleResponse.Response
+						r.RegisterDelayTask(task)
 
 					}
 					break
diff --git a/pkg/service/asChat/robot/task.go b/pkg/service/asChat/robot/task.go
index 94644d7..d64ea7f 100644
--- a/pkg/service/asChat/robot/task.go
+++ b/pkg/service/asChat/robot/task.go
@@ -6,10 +6,15 @@
 // -------------------------------------------
 package robot
 
-import "time"
+import (
+	"fonchain-fiee/api/accountFiee"
+	"fonchain-fiee/pkg/service/asChat/chatCache"
+	"time"
+)
 
 type RobotTask struct {
 	RunTime  time.Time
-	Run      func(msg string) error
+	Run      func(msg string, cache *chatCache.ChatCache, Sender *accountFiee.ChatUserData) error
 	Response string
+	ChatUser *accountFiee.ChatUserData
 }