mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 19:43:49 +08:00
commit
be47ff3437
12
coolq/bot.go
12
coolq/bot.go
@ -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 == "" {
|
||||||
|
@ -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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user