Skip to content

Commit

Permalink
fix: 无法发送语音
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Sep 11, 2024
1 parent e2b8230 commit 0e764e1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions coolq/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ func (bot *CQBot) uploadLocalVideo(target message.Source, v *msg.LocalVideo) (*m
func removeLocalElement(elements []message.IMessageElement) []message.IMessageElement {
var j int
for i, e := range elements {
switch elem := e.(type) {
switch e.(type) {
case *msg.LocalImage, *msg.LocalVideo:
// todo 这里先不要删,语音消息暂时没有本地表示
case *message.VoiceElement: // 未上传的语音消息, 也删除
if elem.MsgInfo != nil {
continue
}
//case *message.VoiceElement: // 未上传的语音消息, 也删除
// if elem.MsgInfo == nil {
// continue
// }
case nil:
default:
if j < i {
Expand Down Expand Up @@ -426,12 +426,12 @@ func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage, source message.Sou
return ok
})
msg := &db.StoredGroupMessage{
ID: encodeMessageID(int64(m.GroupUin), m.Id),
GlobalID: db.ToGlobalID(int64(m.GroupUin), m.Id),
ID: encodeMessageID(int64(m.GroupUin), int32(m.Id)),
GlobalID: db.ToGlobalID(int64(m.GroupUin), int32(m.Id)),
SubType: "normal",
Attribute: &db.StoredMessageAttribute{
MessageSeq: m.Id,
InternalID: m.InternalId,
MessageSeq: int32(m.Id),
InternalID: int32(m.InternalId),
SenderUin: int64(m.Sender.Uin),
SenderName: m.Sender.CardName,
Timestamp: int64(m.Time),
Expand Down Expand Up @@ -469,23 +469,23 @@ func (bot *CQBot) InsertPrivateMessage(m *message.PrivateMessage, source message
return ok
})
msg := &db.StoredPrivateMessage{
ID: encodeMessageID(int64(m.Sender.Uin), m.Id),
GlobalID: db.ToGlobalID(int64(m.Sender.Uin), m.Id),
ID: encodeMessageID(int64(m.Sender.Uin), int32(m.Id)),
GlobalID: db.ToGlobalID(int64(m.Sender.Uin), int32(m.Id)),
SubType: "normal",
Attribute: &db.StoredMessageAttribute{
MessageSeq: m.Id,
InternalID: m.InternalId,
MessageSeq: int32(m.Id),
InternalID: int32(m.InternalId),
SenderUin: int64(m.Sender.Uin),
SenderName: m.Sender.Nickname,
Timestamp: int64(m.Time),
},
SessionUin: func() int64 {
if int64(m.Sender.Uin) == m.Self {
return m.Target
if m.Sender.Uin == m.Self {
return int64(m.Target)
}
return int64(m.Sender.Uin)
}(),
TargetUin: m.Target,
TargetUin: int64(m.Target),
Content: ToMessageContent(m.Elements, source),
}
if replyElem != nil {
Expand Down

0 comments on commit 0e764e1

Please sign in to comment.