mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-06-19 14:05:03 +08:00
remove message.ShortVideoElement in LocalVideoElement
This commit is contained in:
parent
5b705273c2
commit
84488f9bf1
@ -212,7 +212,6 @@ func (bot *CQBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElemen
|
||||
|
||||
// UploadLocalVideo 上传本地短视频至群聊
|
||||
func (bot *CQBot) UploadLocalVideo(target int64, v *LocalVideoElement) (*message.ShortVideoElement, error) {
|
||||
if v.File != "" {
|
||||
video, err := os.Open(v.File)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -224,8 +223,6 @@ func (bot *CQBot) UploadLocalVideo(target int64, v *LocalVideoElement) (*message
|
||||
_, _ = v.thumb.Seek(0, io.SeekStart)
|
||||
return bot.Client.UploadGroupShortVideo(target, video, v.thumb, cacheFile)
|
||||
}
|
||||
return &v.ShortVideoElement, nil
|
||||
}
|
||||
|
||||
// UploadLocalImageAsPrivate 上传本地图片至私聊
|
||||
func (bot *CQBot) UploadLocalImageAsPrivate(userID int64, img *LocalImageElement) (i *message.FriendImageElement, err error) {
|
||||
|
@ -81,7 +81,6 @@ type LocalVoiceElement struct {
|
||||
|
||||
// LocalVideoElement 本地视频
|
||||
type LocalVideoElement struct {
|
||||
message.ShortVideoElement
|
||||
File string
|
||||
thumb io.ReadSeeker
|
||||
}
|
||||
@ -97,6 +96,11 @@ func (e *GiftElement) Type() message.ElementType {
|
||||
return message.At
|
||||
}
|
||||
|
||||
// Type impl message.IMessageElement
|
||||
func (e *LocalVideoElement) Type() message.ElementType {
|
||||
return message.Video
|
||||
}
|
||||
|
||||
// GiftID 礼物ID数组
|
||||
var GiftID = [...]message.GroupGift{
|
||||
message.SweetWink,
|
||||
@ -902,7 +906,10 @@ func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m inte
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
v := file.(*LocalVideoElement)
|
||||
v, ok := file.(*LocalVideoElement)
|
||||
if !ok {
|
||||
return file, nil
|
||||
}
|
||||
if v.File == "" {
|
||||
return v, nil
|
||||
}
|
||||
@ -1124,14 +1131,14 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) (
|
||||
if path.Ext(rawPath) == ".video" {
|
||||
b, _ := os.ReadFile(rawPath)
|
||||
r := binary.NewReader(b)
|
||||
return &LocalVideoElement{ShortVideoElement: message.ShortVideoElement{ // todo 检查缓存是否有效
|
||||
return &message.ShortVideoElement{ // todo 检查缓存是否有效
|
||||
Md5: r.ReadBytes(16),
|
||||
ThumbMd5: r.ReadBytes(16),
|
||||
Size: r.ReadInt32(),
|
||||
ThumbSize: r.ReadInt32(),
|
||||
Name: r.ReadString(),
|
||||
Uuid: r.ReadAvailable(),
|
||||
}}, nil
|
||||
}, nil
|
||||
}
|
||||
return &LocalVideoElement{File: rawPath}, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user