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

Test4 #60

Merged
merged 116 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
fad0d50
Compiled main.go and pushed changes
Hoshinonyaruko Oct 23, 2023
fda2572
test
Hoshinonyaruko Oct 23, 2023
34cfac1
适配了频道私聊,用bolt数据库取代ini
Hoshinonyaruko Oct 23, 2023
7fc1f10
适配了nonebot2
Hoshinonyaruko Oct 24, 2023
28f9a73
Merge branch 'main' of https://github.com/Hoshinonyaruko/Gensokyo
Hoshinonyaruko Oct 24, 2023
9fadda4
适配私域
Hoshinonyaruko Oct 24, 2023
1336c6a
add license
Hoshinonyaruko Oct 24, 2023
b094949
add a lot
Hoshinonyaruko Oct 25, 2023
f4787f5
Resolved merge conflicts
Hoshinonyaruko Oct 25, 2023
86698c6
trss support
Hoshinonyaruko Oct 26, 2023
045f3e9
fix
Hoshinonyaruko Oct 26, 2023
618561c
add action
Hoshinonyaruko Oct 26, 2023
7e803aa
add action
Hoshinonyaruko Oct 26, 2023
ece4cef
add action
Hoshinonyaruko Oct 26, 2023
f864a50
fixbug
Hoshinonyaruko Oct 26, 2023
4564731
add wss
Hoshinonyaruko Oct 26, 2023
070e4df
merge
Hoshinonyaruko Oct 26, 2023
84e8fe9
bugfix
Hoshinonyaruko Oct 26, 2023
0e4fd50
fix action
Hoshinonyaruko Oct 26, 2023
fe2234a
fix action again
Hoshinonyaruko Oct 26, 2023
cf67a11
fix action againnn
Hoshinonyaruko Oct 26, 2023
0875837
fa
Hoshinonyaruko Oct 26, 2023
3a3c33f
fix
Hoshinonyaruko Oct 26, 2023
8789fa8
add a lot
Hoshinonyaruko Oct 27, 2023
7943466
add ws server token
Hoshinonyaruko Oct 28, 2023
4660983
merge
Hoshinonyaruko Oct 28, 2023
2a1026a
bugifx
Hoshinonyaruko Oct 28, 2023
4186970
fix
Hoshinonyaruko Oct 28, 2023
2f26828
fixat
Hoshinonyaruko Oct 28, 2023
007e1af
bugfix
Hoshinonyaruko Oct 28, 2023
c41fd77
bugfix
Hoshinonyaruko Oct 28, 2023
d8354b7
test
Hoshinonyaruko Oct 28, 2023
6e3c63c
test
Hoshinonyaruko Oct 28, 2023
f08d9d7
test2
Hoshinonyaruko Oct 28, 2023
4dd6e15
add url service
Hoshinonyaruko Oct 31, 2023
1f8c174
add url service
Hoshinonyaruko Oct 31, 2023
240f569
add url service
Hoshinonyaruko Oct 31, 2023
b191cb7
bugfix
Hoshinonyaruko Oct 31, 2023
42daab3
merge
Hoshinonyaruko Oct 31, 2023
8fec03f
fix
Hoshinonyaruko Oct 31, 2023
cca528b
fix
Hoshinonyaruko Oct 31, 2023
463a182
fix
Hoshinonyaruko Oct 31, 2023
e9187a1
bug fix
Hoshinonyaruko Nov 1, 2023
5ba2815
fix
Hoshinonyaruko Nov 1, 2023
c16e1af
fix
Hoshinonyaruko Nov 1, 2023
ec7863d
test
Hoshinonyaruko Nov 2, 2023
e8a7e73
ok
Hoshinonyaruko Nov 2, 2023
122d17d
add webui
Hoshinonyaruko Nov 2, 2023
4e9c209
merge
Hoshinonyaruko Nov 2, 2023
b502d61
add image_compress
Hoshinonyaruko Nov 3, 2023
3519e3e
merge
Hoshinonyaruko Nov 3, 2023
530ff96
bug fix
Hoshinonyaruko Nov 3, 2023
155a701
fix cq code
Hoshinonyaruko Nov 3, 2023
2f5ee4a
fixbug
Hoshinonyaruko Nov 3, 2023
afa03e3
bugfix
Hoshinonyaruko Nov 3, 2023
fdd1a73
merge
Hoshinonyaruko Nov 3, 2023
fe39cd2
bugfix
Hoshinonyaruko Nov 3, 2023
be08cbe
bugfix
Hoshinonyaruko Nov 3, 2023
931dfef
merge
Hoshinonyaruko Nov 3, 2023
73819c8
bugfix
Hoshinonyaruko Nov 3, 2023
b27f062
bugfix
Hoshinonyaruko Nov 3, 2023
1a94197
bugfix
Hoshinonyaruko Nov 3, 2023
745b28e
bugfix
Hoshinonyaruko Nov 3, 2023
1212c9a
bugfix
Hoshinonyaruko Nov 4, 2023
44d8669
bugfix
Hoshinonyaruko Nov 4, 2023
564aba5
add new feature
Hoshinonyaruko Nov 5, 2023
d7345c1
bugfix
Hoshinonyaruko Nov 5, 2023
472a224
bugfix
Hoshinonyaruko Nov 5, 2023
e22b58b
bugfix
Hoshinonyaruko Nov 5, 2023
22cb473
bugfix
Hoshinonyaruko Nov 5, 2023
e563929
bugfix
Hoshinonyaruko Nov 5, 2023
829b5d7
merge
Hoshinonyaruko Nov 5, 2023
b496ac1
bugfix
Hoshinonyaruko Nov 5, 2023
13e7700
bugfix
Hoshinonyaruko Nov 5, 2023
eb7e630
bugfix
Hoshinonyaruko Nov 5, 2023
32d490f
test
Hoshinonyaruko Nov 5, 2023
9815e3a
test
Hoshinonyaruko Nov 5, 2023
7747de6
test
Hoshinonyaruko Nov 5, 2023
fe2e4be
test
Hoshinonyaruko Nov 5, 2023
ec9e797
test
Hoshinonyaruko Nov 5, 2023
3548108
test
Hoshinonyaruko Nov 5, 2023
1e50a7c
test
Hoshinonyaruko Nov 5, 2023
812e6ea
test
Hoshinonyaruko Nov 5, 2023
76363a6
test
Hoshinonyaruko Nov 5, 2023
d8b05cd
test
Hoshinonyaruko Nov 5, 2023
c2e2b20
test
Hoshinonyaruko Nov 5, 2023
cefac16
test
Hoshinonyaruko Nov 5, 2023
273db15
test
Hoshinonyaruko Nov 5, 2023
5379f7d
test
Hoshinonyaruko Nov 5, 2023
56e2429
test
Hoshinonyaruko Nov 5, 2023
4466f30
test
Hoshinonyaruko Nov 6, 2023
a32a124
test
Hoshinonyaruko Nov 6, 2023
246d9c4
test
Hoshinonyaruko Nov 6, 2023
c91d9e2
test
Hoshinonyaruko Nov 6, 2023
6007979
bugfix
Hoshinonyaruko Nov 6, 2023
af64c33
bugfix
Hoshinonyaruko Nov 6, 2023
f5cfda3
Remove dist directory from tracking
Hoshinonyaruko Nov 6, 2023
53b6e5d
test
Hoshinonyaruko Nov 6, 2023
3991193
test
Hoshinonyaruko Nov 7, 2023
7af6759
bugfix2
Hoshinonyaruko Nov 7, 2023
fdec4ca
bugfix3
Hoshinonyaruko Nov 7, 2023
849c638
bugfix4
Hoshinonyaruko Nov 7, 2023
f268f3d
bugfix5
Hoshinonyaruko Nov 7, 2023
7ada595
bugfix5
Hoshinonyaruko Nov 8, 2023
76376a0
bugfix6
Hoshinonyaruko Nov 8, 2023
8332932
bugfix7
Hoshinonyaruko Nov 8, 2023
ac05d43
bugfix8
Hoshinonyaruko Nov 8, 2023
47b672c
bugfix9
Hoshinonyaruko Nov 8, 2023
9146fd8
bugfix10
Hoshinonyaruko Nov 8, 2023
8b399fb
bugfix11
Hoshinonyaruko Nov 9, 2023
c768a76
bugfix11
Hoshinonyaruko Nov 9, 2023
b07e71a
bugfix12
Hoshinonyaruko Nov 9, 2023
0a0aaf8
bugfix13
Hoshinonyaruko Nov 9, 2023
397927a
bugfix14
Hoshinonyaruko Nov 9, 2023
4c6f0b5
add feature
Hoshinonyaruko Nov 9, 2023
246b7d5
add feature
Hoshinonyaruko Nov 9, 2023
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
5 changes: 5 additions & 0 deletions Processor/ProcessC2CMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ 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())
//储存类型
echo.AddMsgType(AppIDString, userid64, "group_private")
//储存当前群或频道号的类型 私信不需要
//idmap.WriteConfigv2(data.ChannelID, "type", "group_private")
Expand Down Expand Up @@ -162,6 +165,8 @@ func (p *Processors) ProcessC2CMessage(data *dto.WSC2CMessageData) error {
//为不支持双向echo的ob服务端映射
echo.AddMsgID(AppIDString, userid64, data.ID)
echo.AddMsgType(AppIDString, userid64, "group_private")
//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(userid64, 10), data.ID, time.Now())

//调试
PrintStructWithFieldNames(groupMsg)
Expand Down
6 changes: 6 additions & 0 deletions Processor/ProcessChannelDirectMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
//其实不需要用AppIDString,因为gensokyo是单机器人框架
echo.AddMsgID(AppIDString, userid64, data.ID)
echo.AddMsgType(AppIDString, userid64, "guild_private")
//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(userid64, 10), data.ID, time.Now())

// 调试
PrintStructWithFieldNames(privateMsg)
Expand Down Expand Up @@ -182,6 +184,8 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
//储存当前群或频道号的类型
idmap.WriteConfigv2(data.ChannelID, "type", "guild_private")
//todo 完善频道类型信息转换
//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(userid64, 10), data.ID, time.Now())

//调试
PrintStructWithFieldNames(onebotMsg)
Expand Down Expand Up @@ -273,6 +277,8 @@ func (p *Processors) ProcessChannelDirectMessage(data *dto.WSDirectMessageData)
//储存当前群或频道号的类型
idmap.WriteConfigv2(fmt.Sprint(ChannelID64), "type", "guild_private")
echo.AddMsgType(AppIDString, ChannelID64, "guild_private")
//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(userid64, 10), data.ID, time.Now())

//调试
PrintStructWithFieldNames(groupMsg)
Expand Down
2 changes: 2 additions & 0 deletions Processor/ProcessGroupMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (p *Processors) ProcessGroupMessage(data *dto.WSGroupATMessageData) error {
//储存当前群或频道号的类型
idmap.WriteConfigv2(fmt.Sprint(GroupID64), "type", "group")
echo.AddMsgType(AppIDString, GroupID64, "group")
//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(GroupID64, 10), data.ID, time.Now())
// 调试
PrintStructWithFieldNames(groupMsg)

Expand Down
4 changes: 4 additions & 0 deletions Processor/ProcessGuildATMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func (p *Processors) ProcessGuildATMessage(data *dto.WSATMessageData) error {
//储存当前群或频道号的类型
idmap.WriteConfigv2(data.ChannelID, "type", "guild")
//todo 完善频道转换
//懒message_id池
echo.AddLazyMessageId(data.ChannelID, data.ID, time.Now())

//调试
PrintStructWithFieldNames(onebotMsg)
Expand Down Expand Up @@ -187,6 +189,8 @@ func (p *Processors) ProcessGuildATMessage(data *dto.WSATMessageData) error {
//储存当前群或频道号的类型
idmap.WriteConfigv2(fmt.Sprint(ChannelID64), "type", "guild")
echo.AddMsgType(AppIDString, ChannelID64, "guild")
//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(ChannelID64, 10), data.ID, time.Now())

//调试
PrintStructWithFieldNames(groupMsg)
Expand Down
4 changes: 4 additions & 0 deletions Processor/ProcessGuildNormalMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ func (p *Processors) ProcessGuildNormalMessage(data *dto.WSMessageData) error {
//储存当前群或频道号的类型
idmap.WriteConfigv2(data.ChannelID, "type", "guild")
//todo 完善频道ob信息
//懒message_id池
echo.AddLazyMessageId(data.ChannelID, data.ID, time.Now())

//调试
PrintStructWithFieldNames(onebotMsg)
Expand Down Expand Up @@ -189,6 +191,8 @@ func (p *Processors) ProcessGuildNormalMessage(data *dto.WSMessageData) error {
//储存当前群或频道号的类型
idmap.WriteConfigv2(fmt.Sprint(ChannelID64), "type", "guild")
echo.AddMsgType(AppIDString, ChannelID64, "guild")
//懒message_id池
echo.AddLazyMessageId(strconv.FormatInt(ChannelID64, 10), data.ID, time.Now())

//调试
PrintStructWithFieldNames(groupMsg)
Expand Down
6 changes: 3 additions & 3 deletions Processor/Processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type OnebotChannelMessage struct {
Avatar string `json:"avatar"`
UserID int64 `json:"user_id"`
RawMessage string `json:"raw_message"`
Echo string `json:"echo"`
Echo string `json:"echo,omitempty"`
}

// 群信息事件
Expand All @@ -64,7 +64,7 @@ type OnebotGroupMessage struct {
SubType string `json:"sub_type"`
Time int64 `json:"time"`
Avatar string `json:"avatar"`
Echo string `json:"echo"`
Echo string `json:"echo,omitempty"`
Message interface{} `json:"message"` // For array format
MessageSeq int `json:"message_seq"`
Font int `json:"font"`
Expand All @@ -82,7 +82,7 @@ type OnebotPrivateMessage struct {
SubType string `json:"sub_type"`
Time int64 `json:"time"`
Avatar string `json:"avatar"`
Echo string `json:"echo"`
Echo string `json:"echo,omitempty"`
Message interface{} `json:"message"` // For array format
MessageSeq int `json:"message_seq"` // Optional field
Font int `json:"font"` // Optional field
Expand Down
13 changes: 13 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type Settings struct {
Title string `yaml:"title"`
HashID bool `yaml:"hash_id"`
TwoWayEcho bool `yaml:"twoway_echo"`
LazyMessageId bool `yaml:"lazy_message_id"`
}

// LoadConfig 从文件中加载配置并初始化单例配置
Expand Down Expand Up @@ -403,6 +404,18 @@ func GetTwoWayEcho() bool {
return instance.Settings.TwoWayEcho
}

// 获取LazyMessageId状态
func GetLazyMessageId() bool {
mu.Lock()
defer mu.Unlock()

if instance == nil {
mylog.Println("Warning: instance is nil when trying to get LazyMessageId value.")
return false
}
return instance.Settings.LazyMessageId
}

// 获取HashID
func GetHashIDValue() bool {
mu.Lock()
Expand Down
61 changes: 61 additions & 0 deletions echo/messageidmap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package echo

import (
"math/rand"
"sync"
"time"
)

type messageRecord struct {
messageID string
timestamp time.Time
}

type messageStore struct {
mu sync.RWMutex
records map[string][]messageRecord
}

var instance *messageStore
var once sync.Once

// 惰性初始化
func initInstance() *messageStore {
once.Do(func() {
instance = &messageStore{
records: make(map[string][]messageRecord),
}
})
return instance
}

// AddLazyMessageId 添加 message_id 和它的时间戳到指定群号
func AddLazyMessageId(groupID, messageID string, timestamp time.Time) {
store := initInstance()
store.mu.Lock()
defer store.mu.Unlock()
store.records[groupID] = append(store.records[groupID], messageRecord{messageID: messageID, timestamp: timestamp})
}

// GetRecentMessages 获取指定群号中最近5分钟内的 message_id
func GetLazyMessagesId(groupID string) string {
store := initInstance()
store.mu.RLock()
defer store.mu.RUnlock()

fiveMinutesAgo := time.Now().Add(-5 * time.Minute)
var recentMessages []string
for _, record := range store.records[groupID] {
if record.timestamp.After(fiveMinutesAgo) {
recentMessages = append(recentMessages, record.messageID)
}
}
var randomMessageID string
if len(recentMessages) > 0 {
randomIndex := rand.Intn(len(recentMessages))
randomMessageID = recentMessages[randomIndex]
} else {
randomMessageID = ""
}
return randomMessageID
}
2 changes: 0 additions & 2 deletions handlers/get_login_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,4 @@ func getLoginInfo(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Open
} else {
mylog.Printf("响应get_login_info: %+v", outputMap)
}

return
}
45 changes: 45 additions & 0 deletions handlers/mark_msg_as_read.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package handlers

import (
"github.com/hoshinonyaruko/gensokyo/callapi"
"github.com/hoshinonyaruko/gensokyo/mylog"
"github.com/tencent-connect/botgo/openapi"
"github.com/tidwall/gjson"
)

type MarkThisMessageAsReadAPIResponse struct {
Status string `json:"status"`
Data gjson.Result `json:"data"`
Msg string `json:"msg"`
Wording string `json:"wording"`
RetCode int64 `json:"retcode"`
Echo interface{} `json:"echo"`
}

func init() {
callapi.RegisterHandler("mark_msg_as_read", MarkThisMessageAsRead)
}

func MarkThisMessageAsRead(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) {

var response MarkThisMessageAsReadAPIResponse

response.Data.Str = "123"
response.Msg = "123"
response.RetCode = 0
response.Status = "ok"
response.Echo = message.Echo

// Convert the members slice to a map
outputMap := structToMap(response)

mylog.Printf("mark_msg_as_read: %+v\n", outputMap)

err := client.SendMessage(outputMap)
if err != nil {
mylog.Printf("Error sending message via client: %v", err)
} else {
mylog.Printf("响应mark_msg_as_read: %+v", outputMap)
}

}
13 changes: 10 additions & 3 deletions handlers/send_group_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ func handleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openap

// 使用 echo 获取消息ID
var messageID string
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取群组发信息对应的message_id:", messageID)
if config.GetLazyMessageId() {
//由于实现了Params的自定义unmarshell 所以可以类型安全的断言为string
messageID = echo.GetLazyMessagesId(message.Params.GroupID.(string))
mylog.Printf("GetLazyMessagesId: %v", messageID)
}
if messageID == "" {
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取群组发信息对应的message_id:", messageID)
}
}
//通过bolt数据库还原真实的GroupID
originalGroupID, err := idmap.RetrieveRowByIDv2(message.Params.GroupID.(string))
Expand Down
13 changes: 10 additions & 3 deletions handlers/send_guild_channel_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ func handleSendGuildChannelMsg(client callapi.Client, api openapi.OpenAPI, apiv2
//mylog.Printf("发送文本信息失败: %v,%v", channelID, channelID)
// 使用 echo 获取消息ID
var messageID string
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取频道发信息对应的message_id:", messageID)
if config.GetLazyMessageId() {
//由于实现了Params的自定义unmarshell 所以可以类型安全的断言为string
messageID = echo.GetLazyMessagesId(channelID)
mylog.Printf("GetLazyMessagesId: %v", messageID)
}
if messageID == "" {
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取频道发信息对应的message_id:", messageID)
}
}
// 如果messageID为空,通过函数获取
if messageID == "" {
Expand Down
28 changes: 21 additions & 7 deletions handlers/send_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,19 @@ func handleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope
case "group":
// 解析消息内容
messageText, foundItems := parseMessageContent(message.Params)

// 使用 echo 获取消息ID
var messageID string
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取群组发信息对应的message_id:", messageID)
if config.GetLazyMessageId() {
//由于实现了Params的自定义unmarshell 所以可以类型安全的断言为string
messageID = echo.GetLazyMessagesId(message.Params.GroupID.(string))
mylog.Printf("GetLazyMessagesId: %v", messageID)
}
//判断是否使用了懒messageid,如果没有,优先从echo获取messageid
if messageID == "" {
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取群组发信息对应的message_id:", messageID)
}
}
mylog.Println("群组发信息messageText:", messageText)
//通过bolt数据库还原真实的GroupID
Expand Down Expand Up @@ -159,9 +166,16 @@ func handleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope

// 使用 echo 获取消息ID
var messageID string
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取私聊发信息对应的message_id:", messageID)
if config.GetLazyMessageId() {
//由于实现了Params的自定义unmarshell 所以可以类型安全的断言为string
messageID = echo.GetLazyMessagesId(UserID)
mylog.Printf("GetLazyMessagesId: %v", messageID)
}
if messageID == "" {
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取私聊发信息对应的message_id:", messageID)
}
}
// 如果messageID为空,通过函数获取
if messageID == "" {
Expand Down
26 changes: 20 additions & 6 deletions handlers/send_private_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,16 @@ func handleSendPrivateMsg(client callapi.Client, api openapi.OpenAPI, apiv2 open

// 使用 echo 获取消息ID
var messageID string
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取私聊发信息对应的message_id:", messageID)
if config.GetLazyMessageId() {
//由于实现了Params的自定义unmarshell 所以可以类型安全的断言为string
messageID = echo.GetLazyMessagesId(UserID)
mylog.Printf("GetLazyMessagesId: %v", messageID)
}
if messageID == "" {
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取私聊发信息对应的message_id:", messageID)
}
}
// 如果messageID仍然为空,尝试使用config.GetAppID和UserID的组合来获取messageID
// 如果messageID为空,通过函数获取
Expand Down Expand Up @@ -175,9 +182,16 @@ func handleSendGuildChannelPrivateMsg(client callapi.Client, api openapi.OpenAPI

// 使用 echo 获取消息ID
var messageID string
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取私聊发信息对应的message_id:", messageID)
if config.GetLazyMessageId() {
//由于实现了Params的自定义unmarshell 所以可以类型安全的断言为string
messageID = echo.GetLazyMessagesId(message.Params.UserID.(string))
mylog.Printf("GetLazyMessagesId: %v", messageID)
}
if messageID == "" {
if echoStr, ok := message.Echo.(string); ok {
messageID = echo.GetMsgIDByKey(echoStr)
mylog.Println("echo取私聊发信息对应的message_id:", messageID)
}
}
mylog.Println("私聊信息messageText:", messageText)
//mylog.Println("foundItems:", foundItems)
Expand Down
2 changes: 1 addition & 1 deletion handlers/set_group_whole_ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func init() {
callapi.RegisterHandler("get_group_whole_ban", setGroupBan)
callapi.RegisterHandler("get_group_whole_ban", setGroupWholeBan)
}

func setGroupWholeBan(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) {
Expand Down
Loading
Loading