Skip to content

Commit

Permalink
Beta147 (#146)
Browse files Browse the repository at this point in the history
* beta1

* beta2

* beta3

* beta4

* beta5

* beta6

* beta7

* beta8

* beta9

* beta10

* beta11

* beta12

* beta13

* beta14

* beta15

* beta16

* beta16

* beta19

* beta20

* beta21

* beta22

* beta23

* beta24

* beta25

* beta27

* beta28

* beta29

* beta30

* beta31

* beta33

* beta34

* beta35

* beta36

* beta37

* beta38

* beta39

* beta40

* beta41

* beta42

* beta43

* beta44

* beta45

* beta45

* beta46

* beat48

* beta49

* beta50

* beta51

* beta52

* beta53

* beta54

* beta55

* beta57

* beta58

* beta59

* beta61

* beta62

* beta63

* beta63

* beta64

* beta65

* beta66

* beta67

* beta70

* beta71

* beta72

* beta72

* beta74

* beta75

* beta76

* beta77

* beta78

* beta79

* beta80

* beta81

* beta82

* beta83

* beta85

* beta86

* beta87

* beta88

* beta89

* beta90

* beta91

* beta92

* beta93

* beta94

* beta94

* beta96

* beta97

* beta98

* beta99

* beta100

* beta101

* beta102

* beta104

* beta105

* beta106

* beta107

* beta108

* beta109

* beta110

* beta111

* beta112

* beta113

* beta115

* beta116

* beta117

* beta118

* beta119

* beta120

* beta121

* beta122

* beta123

* beta124

* beta125

* beta126

* beta127

* beta128

* beta129

* beta130

* beta131

* beta132

* beta1333

* beta134

* beta135

* beta136

* beta137

* beta138

* beta139

* beta140

* beta141

* beta142

* beta143

* beta144

* beta145

* beta146
  • Loading branch information
Hoshinonyaruko authored Jun 15, 2024
1 parent a5d1b79 commit eb5fdd0
Show file tree
Hide file tree
Showing 13 changed files with 858 additions and 537 deletions.
502 changes: 177 additions & 325 deletions applogic/flow.go

Large diffs are not rendered by default.

21 changes: 9 additions & 12 deletions applogic/gensokyo.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,12 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
}

// 提示词之间流转 达到信号量
markType := config.GetPromptMarkType(promptstr)
if (markType == 0 || markType == 1) && (CustomRecord.PromptStrStat-1 <= 0) {
if CustomRecord.PromptStrStat-1 <= 0 {
PromptMarks := config.GetPromptMarks(promptstr)
if len(PromptMarks) != 0 {
randomIndex := rand.Intn(len(PromptMarks))
newPromptStr := PromptMarks[randomIndex]

// 如果 markType 是 1,提取 "aaa" 部分
if markType == 1 {
parts := strings.Split(newPromptStr, ":")
if len(parts) > 0 {
newPromptStr = parts[0] // 取冒号前的部分作为新的提示词
}
}
selectedBranch := PromptMarks[randomIndex]
newPromptStr := selectedBranch.BranchName

// 刷新新的提示词给用户目前的状态 新的场景应该从1开始
if config.GetGroupContext() == 2 && message.MessageType != "private" {
Expand All @@ -239,7 +231,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
app.InsertCustomTableRecord(message.UserID+message.SelfID, newPromptStr, 1)
}

fmt.Printf("流转prompt参数: %s,newPromptStrStat:%d\n", newPromptStr, 1)
fmt.Printf("流转prompt参数: %s, newPromptStrStat: %d\n", newPromptStr, 1)
promptstr = newPromptStr
}
}
Expand Down Expand Up @@ -659,6 +651,8 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
requestmsg = acnode.CheckWordIN(requestmsg)
}

// MARK: 对当前的Q进行各种处理

// 关键词退出部分ExitChoicesQ
app.ProcessExitChoicesQ(promptstr, &requestmsg, &message, selfid) // 适配群

Expand All @@ -671,6 +665,9 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
// promptstr 随 switchOnQ 变化 切换Q
app.ApplySwitchOnQ(&promptstr, &requestmsg, &message) // 适配群

// 概率的添加内容到当前的Q后方
app.ApplyPromptChanceQ(promptstr, &requestmsg, &message) // 适配群

// 从数据库读取用户的剧情存档
var CustomRecord *structs.CustomRecord
if config.GetGroupContext() == 2 && message.MessageType != "private" {
Expand Down
38 changes: 12 additions & 26 deletions applogic/promptstr.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,42 +117,28 @@ func fieldIndex(field string) int {
}

func (app *App) ProcessPromptMarks(userID int64, QorA string, promptStr *string) {
// 根据 promptStr 获取 PromptMarkType
markType := config.GetPromptMarkType(*promptStr)

// 如果 markType 是 0,则不执行任何操作
if markType == 0 {
return
}

// 如果 markType 是 1,执行以下操作
if markType == 1 {
// 获取 PromptMarks
PromptMarks := config.GetPromptMarks(*promptStr)
maxMatchCount := 0
bestPromptStr := ""
bestPromptMarksLength := 0

for _, mark := range PromptMarks {
// 提取冒号右侧的文本,并转换为数组
parts := strings.Split(mark, ":")
if len(parts) < 2 {
continue
}
codes := strings.Split(parts[1], "-")
// 获取 PromptMarks
PromptMarks := config.GetPromptMarks(*promptStr)
maxMatchCount := 0
bestPromptStr := ""
bestPromptMarksLength := 0

// 检查 QorA 是否包含数组中的任意一个成员
for _, mark := range PromptMarks {
// 如果没有设置keyword则不处理
if len(mark.Keywords) != 0 {
// 检查 QorA 是否包含 Keywords 中的任意一个成员
matchCount := 0
for _, code := range codes {
if strings.Contains(QorA, code) {
for _, keyword := range mark.Keywords {
if strings.Contains(QorA, keyword) {
matchCount++
}
}

// 更新找到含有最多匹配项的新 promptStr
if matchCount > maxMatchCount {
maxMatchCount = matchCount
bestPromptStr = parts[0]
bestPromptStr = mark.BranchName
bestPromptMarksLength = config.GetPromptMarksLength(bestPromptStr)
}
}
Expand Down
Loading

0 comments on commit eb5fdd0

Please sign in to comment.