1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 19:43:49 +08:00

Merge pull request #548 from wdvxdr1123/patch-2

private video
This commit is contained in:
Mrs4s 2021-01-09 00:27:35 +08:00 committed by GitHub
commit be47ff3437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/gob" "encoding/gob"
"fmt" "fmt"
"hash/crc32" "hash/crc32"
"math/rand"
"os" "os"
"path" "path"
"runtime/debug" "runtime/debug"
@ -281,12 +282,21 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
if i, ok := elem.(*message.VoiceElement); ok { if i, ok := elem.(*message.VoiceElement); ok {
fv, err := bot.Client.UploadPrivatePtt(target, i.Data) fv, err := bot.Client.UploadPrivatePtt(target, i.Data)
if err != nil { if err != nil {
log.Warnf("警告: %v 消息语音上传失败: %v", target, err) log.Warnf("警告: 私聊 %v 消息语音上传失败: %v", target, err)
continue continue
} }
newElem = append(newElem, fv) newElem = append(newElem, fv)
continue continue
} }
if i, ok := elem.(*LocalVideoElement); ok { // todo:cache & multiThread
gv, err := bot.Client.UploadGroupShortVideo(target, i.video, i.thumb)
if err != nil {
log.Warnf("警告: 私聊 %v 消息短视频上传失败: %v", int64(rand.Uint32()), err)
continue
}
newElem = append(newElem, gv)
continue
}
if i, ok := elem.(*QQMusicElement); ok { if i, ok := elem.(*QQMusicElement); ok {
var msgStyle uint32 = 4 var msgStyle uint32 = 4
if i.MusicUrl == "" { if i.MusicUrl == "" {

View File

@ -784,9 +784,6 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interf
} }
return bot.makeShowPic(img, source, icon, minWidth, minHeight, maxWidth, maxHeight, group) return bot.makeShowPic(img, source, icon, minWidth, minHeight, maxWidth, maxHeight, group)
case "video": case "video":
if !group {
return nil, errors.New("unsupported private short video")
}
cache := d["cache"] cache := d["cache"]
if cache == "" { if cache == "" {
cache = "1" cache = "1"