解决冲突
This commit is contained in:
parent
76679696f9
commit
a1e5433af6
1 changed files with 34 additions and 55 deletions
|
|
@ -56,7 +56,6 @@ const (
|
||||||
var emojiRegexp = regexp.MustCompile(`<[^<]*?ext="([^"]+)"[^<]*?faceType=(\d+)[^<]*?>|<[^<]*?faceType=(\d+)[^<]*?ext="([^"]+)"[^<]*?>`)
|
var emojiRegexp = regexp.MustCompile(`<[^<]*?ext="([^"]+)"[^<]*?faceType=(\d+)[^<]*?>|<[^<]*?faceType=(\d+)[^<]*?ext="([^"]+)"[^<]*?>`)
|
||||||
var extRegexp = regexp.MustCompile(`ext="([^"]+)"`)
|
var extRegexp = regexp.MustCompile(`ext="([^"]+)"`)
|
||||||
|
|
||||||
|
|
||||||
type qqAPI interface {
|
type qqAPI interface {
|
||||||
WS(ctx context.Context, params map[string]string, body string) (*dto.WebsocketAP, error)
|
WS(ctx context.Context, params map[string]string, body string) (*dto.WebsocketAP, error)
|
||||||
PostGroupMessage(
|
PostGroupMessage(
|
||||||
|
|
@ -500,8 +499,6 @@ func (c *QQChannel) outboundMediaType(part bus.MediaPart, localPath string) stri
|
||||||
return "audio"
|
return "audio"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Fix the sendUploadedMedia function syntax error
|
// Fix the sendUploadedMedia function syntax error
|
||||||
func (c *QQChannel) sendUploadedMedia(ctx context.Context, chatKind kindType, chatID string, part bus.MediaPart,
|
func (c *QQChannel) sendUploadedMedia(ctx context.Context, chatKind kindType, chatID string, part bus.MediaPart,
|
||||||
fileInfo []byte) error {
|
fileInfo []byte) error {
|
||||||
|
|
@ -515,7 +512,6 @@ func (c *QQChannel) sendUploadedMedia(ctx context.Context, chatKind kindType, ch
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.MsgID, msg.MsgSeq = c.getReplyExtInfo(ctx, chatID)
|
msg.MsgID, msg.MsgSeq = c.getReplyExtInfo(ctx, chatID)
|
||||||
|
|
||||||
if chatKind == kindGroup {
|
if chatKind == kindGroup {
|
||||||
if msg.Content != "" {
|
if msg.Content != "" {
|
||||||
msg.Content = sanitizeURLs(msg.Content)
|
msg.Content = sanitizeURLs(msg.Content)
|
||||||
|
|
@ -610,8 +606,6 @@ func (c *QQChannel) handleC2CMessage() event.C2CMessageEventHandler {
|
||||||
"sender": senderID,
|
"sender": senderID,
|
||||||
"length": len(content),
|
"length": len(content),
|
||||||
"media_count": len(mediaPaths),
|
"media_count": len(mediaPaths),
|
||||||
"sender": senderID,
|
|
||||||
"length": len(content),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Store chat routing context.
|
// Store chat routing context.
|
||||||
|
|
@ -632,7 +626,6 @@ func (c *QQChannel) handleC2CMessage() event.C2CMessageEventHandler {
|
||||||
metadata,
|
metadata,
|
||||||
sender,
|
sender,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -658,19 +651,9 @@ func (c *QQChannel) handleGroupATMessage() event.GroupATMessageEventHandler {
|
||||||
Platform: "qq",
|
Platform: "qq",
|
||||||
PlatformID: data.Author.ID,
|
PlatformID: data.Author.ID,
|
||||||
CanonicalID: identity.BuildCanonicalID("qq", data.Author.ID),
|
CanonicalID: identity.BuildCanonicalID("qq", data.Author.ID),
|
||||||
|
Username: data.Author.Username,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.IsAllowedSender(sender) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
content := strings.TrimSpace(data.Content)
|
|
||||||
mediaPaths, attachmentNotes := c.extractInboundAttachments(data.GroupID, data.ID, data.Attachments)
|
|
||||||
for _, note := range attachmentNotes {
|
|
||||||
content = appendContent(content, note)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if !c.IsAllowedSender(sender) {
|
if !c.IsAllowedSender(sender) {
|
||||||
logger.Infof("qq", "Received group message from unauthorized sender", map[string]any{
|
logger.Infof("qq", "Received group message from unauthorized sender", map[string]any{
|
||||||
"sender": sender,
|
"sender": sender,
|
||||||
|
|
@ -680,7 +663,7 @@ func (c *QQChannel) handleGroupATMessage() event.GroupATMessageEventHandler {
|
||||||
|
|
||||||
scope := channels.BuildMediaScope("qq", data.GroupID, data.ID)
|
scope := channels.BuildMediaScope("qq", data.GroupID, data.ID)
|
||||||
|
|
||||||
content, mediaPaths = c.decodeMessage(context.Background(), event, (*dto.Message)(data), scope)
|
content, mediaPaths := c.decodeMessage(context.Background(), event, (*dto.Message)(data), scope)
|
||||||
if content == "" {
|
if content == "" {
|
||||||
logger.DebugC("qq", "Received empty group message, ignoring")
|
logger.DebugC("qq", "Received empty group message, ignoring")
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -1167,8 +1150,6 @@ func (c *QQChannel) processAttachments(ctx context.Context, attachments []Messag
|
||||||
return mediaPaths, content
|
return mediaPaths, content
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// getAttachmentType determines the type of attachment (image, audio, video, file)
|
// getAttachmentType determines the type of attachment (image, audio, video, file)
|
||||||
func (c *QQChannel) getAttachmentType(attachment MessageAttachment) string {
|
func (c *QQChannel) getAttachmentType(attachment MessageAttachment) string {
|
||||||
if strings.HasPrefix(attachment.ContentType, "image") {
|
if strings.HasPrefix(attachment.ContentType, "image") {
|
||||||
|
|
@ -1237,8 +1218,6 @@ func sanitizeURLs(text string) string {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func getVoiceInfo(event *dto.WSPayload) (string, string) {
|
func getVoiceInfo(event *dto.WSPayload) (string, string) {
|
||||||
_raw, err := json.Marshal(event.Data)
|
_raw, err := json.Marshal(event.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue