40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
|
// Package autoReply -----------------------------
|
|||
|
// @file : KeywordsReplyRuler.go
|
|||
|
// @author : JJXu
|
|||
|
// @contact : wavingbear@163.com
|
|||
|
// @time : 2025/6/13 16:21
|
|||
|
// -------------------------------------------
|
|||
|
package robot
|
|||
|
|
|||
|
import (
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
// 使用go开发一个自动回复功能,
|
|||
|
// 一个自动回复消息有多种触发条件:
|
|||
|
// 1. 关键词触发
|
|||
|
// 2. 进入聊天系统后直接发送
|
|||
|
// 3. 若干秒不回复自动发送
|
|||
|
|
|||
|
//func (k KeywordsRuleChecker) Do(sessionId string, response string, chatRoom *ws.ChatRoom) (err error) {
|
|||
|
// var notice = dto.MessageListType{}
|
|||
|
// notice.BuildMessage(response)
|
|||
|
// _, err = chatRoom.SendSessionMessage(1, sessionId, ws.NewChatMsgType, notice)
|
|||
|
// return nil
|
|||
|
//}
|
|||
|
|
|||
|
type AutoReply struct {
|
|||
|
Response string `json:"response"`
|
|||
|
Rules map[string]IRule `json:"rules"`
|
|||
|
}
|
|||
|
type AutoReplyRule struct {
|
|||
|
Enable bool `json:"enable"`
|
|||
|
Keywords []string `json:"keywords"`
|
|||
|
ReplyTimeout int `json:"replyTimeout"` // 回复超时时间
|
|||
|
}
|
|||
|
|
|||
|
type AutoReplyManager struct {
|
|||
|
replies []AutoReply
|
|||
|
lastMessage time.Time
|
|||
|
}
|