Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta467 #469

Merged
merged 21 commits into from
Jul 21, 2024
42 changes: 32 additions & 10 deletions Processor/ProcessC2CMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,19 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
//收到私聊信息调用的具体还原步骤
//1,idmap还原真实userid,
//发信息使用的是userid

messageID64, err := idmap.StoreCachev2(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
var messageID64 int64
if config.GetMemoryMsgid() {
messageID64, err = echo.StoreCacheInMemory(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
}
} else {
messageID64, err = idmap.StoreCachev2(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
}
}

messageID := int(messageID64)
if config.GetAutoBind() {
if len(data.Attachments) > 0 && data.Attachments[0].URL != "" {
Expand Down Expand Up @@ -139,14 +147,17 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
//其实不需要用AppIDString,因为gensokyo是单机器人框架
//可以试着开发一个,会很棒的
echo.AddMsgID(AppIDString, userid64, data.ID)

//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(userid64, 10), data.ID, time.Now())

//懒message_id池
echo.AddLazyMessageId(data.Author.ID, data.ID, time.Now())

//储存类型
echo.AddMsgType(AppIDString, userid64, "group_private")
//储存当前群或频道号的类型
idmap.WriteConfigv2(fmt.Sprint(userid64), "type", "group_private")
//储存当前群或频道号的类型 私信不需要
//idmap.WriteConfigv2(data.ChannelID, "type", "group_private")

// 调试
PrintStructWithFieldNames(privateMsg)
Expand Down Expand Up @@ -205,10 +216,17 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
//框架内指令
p.HandleFrameworkCommand(messageText, data, "group_private")
//映射str的messageID到int
messageID64, err := idmap.StoreCachev2(data.ID)
if err != nil {
mylog.Printf("Error storing ID: %v", err)
return nil
var messageID64 int64
if config.GetMemoryMsgid() {
messageID64, err = echo.StoreCacheInMemory(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
}
} else {
messageID64, err = idmap.StoreCachev2(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
}
}
messageID := int(messageID64)
//todo 判断array模式 然后对Message处理成array格式
Expand Down Expand Up @@ -287,9 +305,13 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
echo.AddMsgType(AppIDString, userid64, "group_private")
//储存当前群或频道号的类型
idmap.WriteConfigv2(fmt.Sprint(userid64), "type", "group_private")

//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(userid64, 10), data.ID, time.Now())

//懒message_id池
echo.AddLazyMessageId(data.Author.ID, data.ID, time.Now())

//调试
PrintStructWithFieldNames(groupMsg)

Expand Down
29 changes: 22 additions & 7 deletions Processor/ProcessChannelDirectMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,17 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
//3,通过idmap用channelid获取guildid,
//发信息使用的是guildid
//todo 优化数据库读写次数
messageID64, err := idmap.StoreCachev2(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
var messageID64 int64
if config.GetMemoryMsgid() {
messageID64, err = echo.StoreCacheInMemory(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
}
} else {
messageID64, err = idmap.StoreCachev2(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
}
}
messageID := int(messageID64)
//转换at
Expand Down Expand Up @@ -344,10 +352,17 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)

//userid := int(userid64)
//映射str的messageID到int
messageID64, err := idmap.StoreCachev2(data.ID)
if err != nil {
mylog.Printf("Error storing ID: %v", err)
return nil
var messageID64 int64
if config.GetMemoryMsgid() {
messageID64, err = echo.StoreCacheInMemory(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
}
} else {
messageID64, err = idmap.StoreCachev2(data.ID)
if err != nil {
log.Fatalf("Error storing ID: %v", err)
}
}
messageID := int(messageID64)
// 如果在Array模式下, 则处理Message为Segment格式
Expand Down
Loading
Loading