Skip to content

Commit

Permalink
Merge b0e8f4f into dfcfc4f
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko authored Jun 6, 2024
2 parents dfcfc4f + b0e8f4f commit a29c504
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions applogic/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func (app *App) ApplyPromptChoiceQ(promptstr string, requestmsg *string, message *structs.OnebotGroupMessage) {
userid := message.UserID
if config.GetGroupContext() && message.MessageType != "private" {
userid = message.GroupID
userid = message.GroupID + message.SelfID
}

// 检查是否启用了EnhancedQA
Expand Down Expand Up @@ -139,7 +139,7 @@ func (app *App) ApplyPromptChoiceQ(promptstr string, requestmsg *string, message
func (app *App) ApplyPromptCoverQ(promptstr string, requestmsg *string, message *structs.OnebotGroupMessage) {
userid := message.UserID
if config.GetGroupContext() && message.MessageType != "private" {
userid = message.GroupID
userid = message.GroupID + message.SelfID
}

// 检查是否启用了EnhancedQA
Expand Down Expand Up @@ -251,7 +251,7 @@ func (app *App) ApplyPromptCoverQ(promptstr string, requestmsg *string, message
func (app *App) ApplySwitchOnQ(promptstr *string, requestmsg *string, message *structs.OnebotGroupMessage) {
userid := message.UserID
if config.GetGroupContext() && message.MessageType != "private" {
userid = message.GroupID
userid = message.GroupID + message.SelfID
}

// promptstr 随 switchOnQ 变化
Expand Down Expand Up @@ -357,7 +357,7 @@ func (app *App) ProcessExitChoicesQ(promptstr string, requestmsg *string, messag

userid := message.UserID
if config.GetGroupContext() && message.MessageType != "private" {
userid = message.GroupID
userid = message.GroupID + message.SelfID
}

// 获取用户剧情存档中的当前状态
Expand Down Expand Up @@ -434,7 +434,7 @@ func (app *App) ProcessExitChoicesQ(promptstr string, requestmsg *string, messag
func (app *App) HandleExit(exitText string, message *structs.OnebotGroupMessage, selfid string, promptstr string) {
userid := message.UserID
if config.GetGroupContext() && message.MessageType != "private" {
userid = message.GroupID
userid = message.GroupID + message.SelfID
}

fmt.Printf("处理重置操作on:%v", exitText)
Expand All @@ -461,7 +461,7 @@ func (app *App) ProcessExitChoicesA(promptstr string, response *string, message

userid := message.UserID
if config.GetGroupContext() && message.MessageType != "private" {
userid = message.GroupID
userid = message.GroupID + message.SelfID
}

// 获取用户剧情存档中的当前状态
Expand Down Expand Up @@ -538,7 +538,7 @@ func (app *App) ProcessExitChoicesA(promptstr string, response *string, message
func (app *App) ApplySwitchOnA(promptstr *string, response *string, message *structs.OnebotGroupMessage) {
userid := message.UserID
if config.GetGroupContext() && message.MessageType != "private" {
userid = message.GroupID
userid = message.GroupID + message.SelfID
}

// 获取与 switchOnA 相关的选择
Expand Down Expand Up @@ -624,7 +624,7 @@ func (app *App) ApplySwitchOnA(promptstr *string, response *string, message *str
func (app *App) ApplyPromptChoiceA(promptstr string, response string, message *structs.OnebotGroupMessage) string {
userid := message.UserID
if config.GetGroupContext() && message.MessageType != "private" {
userid = message.GroupID
userid = message.GroupID + message.SelfID
}

promptChoices := config.GetPromptChoicesA(promptstr)
Expand Down
26 changes: 13 additions & 13 deletions applogic/gensokyo.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
var CustomRecord *structs.CustomRecord
if config.GetGroupContext() && message.MessageType != "private" {
// 从数据库读取用户的剧情存档
CustomRecord, err = app.FetchCustomRecord(message.GroupID)
CustomRecord, err = app.FetchCustomRecord(message.GroupID + message.SelfID)
if err != nil {
fmt.Printf("app.FetchCustomRecord 出错: %s\n", err)
}
Expand All @@ -197,7 +197,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
newPromptStrStat := CustomRecord.PromptStrStat - 1
// 根据条件区分群和私聊
if config.GetGroupContext() && message.MessageType != "private" {
err = app.InsertCustomTableRecord(message.GroupID, promptstr, newPromptStrStat)
err = app.InsertCustomTableRecord(message.GroupID+message.SelfID, promptstr, newPromptStrStat)
if err != nil {
fmt.Printf("app.InsertCustomTableRecord 出错: %s\n", err)
}
Expand All @@ -211,7 +211,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {

// MARK: 提示词之间 整体切换Q
if config.GetGroupContext() && message.MessageType != "private" {
app.ProcessPromptMarks(message.GroupID, message.Message.(string), &promptstr)
app.ProcessPromptMarks(message.GroupID+message.SelfID, message.Message.(string), &promptstr)
} else {
app.ProcessPromptMarks(message.UserID, message.Message.(string), &promptstr)
}
Expand All @@ -234,7 +234,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {

// 刷新新的提示词给用户目前的状态 新的场景应该从1开始
if config.GetGroupContext() && message.MessageType != "private" {
app.InsertCustomTableRecord(message.GroupID, newPromptStr, 1)
app.InsertCustomTableRecord(message.GroupID+message.SelfID, newPromptStr, 1)
} else {
app.InsertCustomTableRecord(message.UserID, newPromptStr, 1)
}
Expand All @@ -246,7 +246,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
} else {
// MARK: 提示词之间 整体切换Q 当用户没有存档时
if config.GetGroupContext() && message.MessageType != "private" {
app.ProcessPromptMarks(message.GroupID, message.Message.(string), &promptstr)
app.ProcessPromptMarks(message.GroupID+message.SelfID, message.Message.(string), &promptstr)
} else {
app.ProcessPromptMarks(message.UserID, message.Message.(string), &promptstr)
}
Expand All @@ -260,7 +260,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {

// 初始状态就是 1 设置了1000以上长度的是固有场景,不可切换
if config.GetGroupContext() && message.MessageType != "private" {
err = app.InsertCustomTableRecord(message.GroupID, promptstr, newstat)
err = app.InsertCustomTableRecord(message.GroupID+message.SelfID, promptstr, newstat)
} else {
err = app.InsertCustomTableRecord(message.UserID, promptstr, newstat)
}
Expand Down Expand Up @@ -353,7 +353,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
if isResetCommand {
fmtf.Println("处理重置操作")
if config.GetGroupContext() && message.MessageType != "private" {
app.migrateUserToNewContext(message.GroupID)
app.migrateUserToNewContext(message.GroupID + message.SelfID)
} else {
app.migrateUserToNewContext(message.UserID)
}
Expand All @@ -369,7 +369,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
}
// 处理故事情节的重置
if config.GetGroupContext() && message.MessageType != "private" {
app.deleteCustomRecord(message.GroupID)
app.deleteCustomRecord(message.GroupID + message.SelfID)
} else {
app.deleteCustomRecord(message.UserID)
}
Expand Down Expand Up @@ -558,7 +558,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
var conversationID, parentMessageID string
// 请求conversation api 增加当前群/用户上下文
if config.GetGroupContext() && message.MessageType != "private" {
conversationID, parentMessageID, err = app.handleUserContext(message.GroupID)
conversationID, parentMessageID, err = app.handleUserContext(message.GroupID + message.SelfID)
} else {
conversationID, parentMessageID, err = app.handleUserContext(message.UserID)
}
Expand Down Expand Up @@ -674,7 +674,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
// 从数据库读取用户的剧情存档
var CustomRecord *structs.CustomRecord
if config.GetGroupContext() && message.MessageType != "private" {
CustomRecord, err = app.FetchCustomRecord(message.GroupID)
CustomRecord, err = app.FetchCustomRecord(message.GroupID + message.SelfID)
if err != nil {
fmt.Printf("app.FetchCustomRecord 出错: %s\n", err)
}
Expand Down Expand Up @@ -706,7 +706,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
}

if config.GetGroupContext() && message.MessageType != "private" {
fmtf.Printf("实际请求conversation端点内容:[%v]%v\n", message.GroupID, requestmsg)
fmtf.Printf("实际请求conversation端点内容:[%v]%v\n", message.GroupID+message.SelfID, requestmsg)
} else {
fmtf.Printf("实际请求conversation端点内容:[%v]%v\n", message.UserID, requestmsg)
}
Expand Down Expand Up @@ -964,7 +964,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
if lastMessageID != "" {
fmtf.Printf("lastMessageID: %s\n", lastMessageID)
if config.GetGroupContext() && message.MessageType != "private" {
err := app.updateUserContext(message.GroupID, lastMessageID)
err := app.updateUserContext(message.GroupID+message.SelfID, lastMessageID)
if err != nil {
fmtf.Printf("Error updating user context: %v\n", err)
}
Expand Down Expand Up @@ -1069,7 +1069,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) {
// 更新用户上下文
if messageId, ok := responseData["messageId"].(string); ok {
if config.GetGroupContext() && message.MessageType != "private" {
err := app.updateUserContext(message.GroupID, messageId)
err := app.updateUserContext(message.GroupID+message.SelfID, messageId)
if err != nil {
fmtf.Printf("Error updating user context: %v\n", err)
}
Expand Down

0 comments on commit a29c504

Please sign in to comment.