feat(channel/qq): optimize message sending, seq generation, and message parsing
1. Define `kindType` as constants.
2. Set `seq` generation to global incremental, simplifying `seq` handling. (QQ platform validation rule is `chatID + replyMsgID + seq`, and `seq` does not affect display order.)
3. Increase API timeout from 5 seconds to 20 seconds to reduce send timeouts.
4. Prioritize sending messages using Markdown; fall back to plain text if Markdown sending fails. Also remove the `QQConfig.SendMarkdown` configuration option.
5. Restrict `InputNotify` to be sent only for direct messages.
6. Adjust message parsing to support emoji parsing and utilize the platform-provided ASR (Automatic Speech Recognition) content.
This commit is contained in:
parent
42838138b0
commit
3976d897a1
1 changed files with 7 additions and 13 deletions
|
|
@ -772,14 +772,6 @@ func qqAttachmentFilename(attachment MessageAttachment) string {
|
||||||
if attachment.FileName != "" {
|
if attachment.FileName != "" {
|
||||||
return attachment.FileName
|
return attachment.FileName
|
||||||
}
|
}
|
||||||
if attachment.URL != "" {
|
|
||||||
if parsed, err := url.Parse(attachment.URL); err == nil {
|
|
||||||
if base := path.Base(parsed.Path); base != "" && base != "." && base != "/" {
|
|
||||||
return base
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch qqAttachmentKind(attachment) {
|
switch qqAttachmentKind(attachment) {
|
||||||
case "image":
|
case "image":
|
||||||
return "image"
|
return "image"
|
||||||
|
|
@ -799,9 +791,11 @@ func qqAttachmentKind(attachment MessageAttachment) string {
|
||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(contentType, "image/"):
|
case strings.HasPrefix(contentType, "image/"):
|
||||||
return "image"
|
return "image"
|
||||||
case strings.HasPrefix(contentType, "video/"):
|
case strings.HasPrefix(contentType, "video"):
|
||||||
return "video"
|
return "video"
|
||||||
case strings.HasPrefix(contentType, "audio/"), contentType == "application/ogg", contentType == "application/x-ogg":
|
case strings.HasPrefix(contentType, "voice"),
|
||||||
|
strings.HasPrefix(contentType, "audio/"),
|
||||||
|
contentType == "application/ogg", contentType == "application/x-ogg":
|
||||||
return "audio"
|
return "audio"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -824,11 +818,11 @@ func qqAttachmentNote(attachment MessageAttachment) string {
|
||||||
case "image":
|
case "image":
|
||||||
return fmt.Sprintf("[image: %s]", filename)
|
return fmt.Sprintf("[image: %s]", filename)
|
||||||
case "audio":
|
case "audio":
|
||||||
|
if attachment.AsrReferText != "" {
|
||||||
|
return fmt.Sprintf("[audio: %s (%s)]", filename, attachment.AsrReferText)
|
||||||
|
}
|
||||||
return fmt.Sprintf("[audio: %s]", filename)
|
return fmt.Sprintf("[audio: %s]", filename)
|
||||||
case "video":
|
case "video":
|
||||||
if attachment.AsrReferText != "" {
|
|
||||||
return fmt.Sprintf("[video: %s]", attachment.AsrReferText)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("[video: %s]", filename)
|
return fmt.Sprintf("[video: %s]", filename)
|
||||||
default:
|
default:
|
||||||
return fmt.Sprintf("[file: %s]", filename)
|
return fmt.Sprintf("[file: %s]", filename)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue