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

Beta471 #475

Merged
merged 25 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
32 changes: 24 additions & 8 deletions Processor/ProcessGroupAddBot.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@ type GroupRequestEvent struct {
SubType string `json:"sub_type"`
Time int64 `json:"time"`
UserID int64 `json:"user_id"`
RealUserID string `json:"real_user_id,omitempty"` //当前真实uid
RealGroupID string `json:"real_group_id,omitempty"` //当前真实gid
}

// GroupNoticeEvent 表示群通知事件的数据结构
type GroupNoticeEvent struct {
GroupID int64 `json:"group_id"`
NoticeType string `json:"notice_type"`
OperatorID int64 `json:"operator_id"`
PostType string `json:"post_type"`
SelfID int64 `json:"self_id"`
SubType string `json:"sub_type"`
Time int64 `json:"time"`
UserID int64 `json:"user_id"`
GroupID int64 `json:"group_id"`
NoticeType string `json:"notice_type"`
OperatorID int64 `json:"operator_id"`
PostType string `json:"post_type"`
SelfID int64 `json:"self_id"`
SubType string `json:"sub_type"`
Time int64 `json:"time"`
UserID int64 `json:"user_id"`
RealUserID string `json:"real_user_id,omitempty"` //当前真实uid
RealGroupID string `json:"real_group_id,omitempty"` //当前真实gid
}

// 定义了一个符合 Client 接口的 SelfIntroduceClient 结构体
Expand Down Expand Up @@ -113,6 +117,12 @@ func (p *Processors) ProcessGroupAddBot(data *dto.GroupAddBotEvent) error {
Time: timestampInt64,
UserID: userid64,
}
//增强配置
if !config.GetNativeOb11() {
Request.RealUserID = data.OpMemberOpenID
Request.RealGroupID = data.GroupOpenID
}

Notice = GroupNoticeEvent{
GroupID: GroupID64,
NoticeType: "group_increase",
Expand All @@ -123,6 +133,12 @@ func (p *Processors) ProcessGroupAddBot(data *dto.GroupAddBotEvent) error {
Time: timestampInt64,
UserID: userid64,
}
//增强配置
if !config.GetNativeOb11() {
Notice.RealUserID = data.OpMemberOpenID
Notice.RealGroupID = data.GroupOpenID
}

groupMsgMap := structToMap(Request)
//上报信息到onebotv11应用端(正反ws)
go p.BroadcastMessageToAll(groupMsgMap, p.Apiv2, data)
Expand Down
Loading
Loading