feat: add learn response in ai response
This commit is contained in:
parent
4e98143c61
commit
ee6b2712c3
2 changed files with 21 additions and 3 deletions
|
@ -116,7 +116,25 @@ func getMuffinResponse(s *discordgo.Session, question string) (string, error) {
|
|||
return result, nil
|
||||
}
|
||||
|
||||
func getAIResponse(c *Chatbot, user *discordgo.User, question string) (string, error) {
|
||||
func getAIResponse(s *discordgo.Session, c *Chatbot, user *discordgo.User, question string) (string, error) {
|
||||
var data []databases.Learn
|
||||
|
||||
x := rand.Intn(10)
|
||||
|
||||
cur, err := databases.Database.Learns.Find(context.TODO(), bson.D{{Key: "command", Value: question}})
|
||||
if err != nil {
|
||||
return "살려주ㅅ세요", err
|
||||
}
|
||||
|
||||
defer cur.Close(context.TODO())
|
||||
cur.All(context.TODO(), &data)
|
||||
|
||||
if x == 10 && len(data) != 0 {
|
||||
data := data[rand.Intn(len(data))]
|
||||
user, _ := s.User(data.UserId)
|
||||
return fmt.Sprintf("%s\n%s", data.Result, utils.InlineCode(fmt.Sprintf("%s님이 알려주셨어요.", user.Username))), nil
|
||||
}
|
||||
|
||||
contents, err := GetMemory(user.ID)
|
||||
if err != nil {
|
||||
ChatBot.Mode = ChatbotMuffin
|
||||
|
@ -152,6 +170,6 @@ func (c *Chatbot) GetResponse(user *discordgo.User, question string) (string, er
|
|||
case ChatbotMuffin:
|
||||
return getMuffinResponse(c.s, question)
|
||||
default:
|
||||
return getAIResponse(c, user, question)
|
||||
return getAIResponse(c.s, c, user, question)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"git.wh64.net/muffin/goMuffin/utils"
|
||||
)
|
||||
|
||||
const MUFFIN_VERSION = "0.0.0-madeleine_canary.250621a"
|
||||
const MUFFIN_VERSION = "0.0.0-madeleine_canary.250621b"
|
||||
|
||||
var updatedString string = utils.RegexpDecimals.FindAllStringSubmatch(MUFFIN_VERSION, -1)[3][0]
|
||||
|
||||
|
|
Loading…
Reference in a new issue