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

update voice.

This commit is contained in:
Mrs4s 2020-08-08 12:59:49 +08:00
parent b61fe4e43e
commit c854339b2d
4 changed files with 7 additions and 3 deletions

View File

@ -99,7 +99,7 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int
newElem = append(newElem, gm) newElem = append(newElem, gm)
continue continue
} }
if i, ok := elem.(*message.GroupVoiceElement); ok { if i, ok := elem.(*message.VoiceElement); ok {
gv, err := bot.Client.UploadGroupPtt(groupId, i.Data, int32(len(i.Data))) gv, err := bot.Client.UploadGroupPtt(groupId, i.Data, int32(len(i.Data)))
if err != nil { if err != nil {
log.Warnf("警告: 群 %v 消息语音上传失败: %v", groupId, err) log.Warnf("警告: 群 %v 消息语音上传失败: %v", groupId, err)

View File

@ -44,6 +44,8 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st
r += fmt.Sprintf("[CQ:forward,id=%s]", o.ResId) r += fmt.Sprintf("[CQ:forward,id=%s]", o.ResId)
case *message.FaceElement: case *message.FaceElement:
r += fmt.Sprintf(`[CQ:face,id=%d]`, o.Index) r += fmt.Sprintf(`[CQ:face,id=%d]`, o.Index)
case *message.VoiceElement:
r += fmt.Sprintf(`[CQ:record,file=%s]`, o.Name)
case *message.ImageElement: case *message.ImageElement:
if ur { if ur {
r += fmt.Sprintf(`[CQ:image,file=%s]`, o.Filename) r += fmt.Sprintf(`[CQ:image,file=%s]`, o.Filename)
@ -283,7 +285,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
if !global.IsAMR(data) { if !global.IsAMR(data) {
return nil, errors.New("unsupported voice file format (please use AMR file for now)") return nil, errors.New("unsupported voice file format (please use AMR file for now)")
} }
return &message.GroupVoiceElement{Data: data}, nil return &message.VoiceElement{Data: data}, nil
case "face": case "face":
id, err := strconv.Atoi(d["id"]) id, err := strconv.Atoi(d["id"])
if err != nil { if err != nil {

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14 go 1.14
require ( require (
github.com/Mrs4s/MiraiGo v0.0.0-20200808003732-2a32e623270d github.com/Mrs4s/MiraiGo v0.0.0-20200808044635-cd20d7d43dbb
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/guonaihong/gout v0.1.1 github.com/guonaihong/gout v0.1.1

2
go.sum
View File

@ -4,6 +4,8 @@ github.com/Mrs4s/MiraiGo v0.0.0-20200807030850-ed30f7ad5934 h1:LoNjIsnyEQFGP9Ich
github.com/Mrs4s/MiraiGo v0.0.0-20200807030850-ed30f7ad5934/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM= github.com/Mrs4s/MiraiGo v0.0.0-20200807030850-ed30f7ad5934/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200808003732-2a32e623270d h1:K9jHdcO13mLqQB0xm0/ZlY852FoVQJ/WSDwfdmfhDlU= github.com/Mrs4s/MiraiGo v0.0.0-20200808003732-2a32e623270d h1:K9jHdcO13mLqQB0xm0/ZlY852FoVQJ/WSDwfdmfhDlU=
github.com/Mrs4s/MiraiGo v0.0.0-20200808003732-2a32e623270d/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM= github.com/Mrs4s/MiraiGo v0.0.0-20200808003732-2a32e623270d/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200808044635-cd20d7d43dbb h1:XLe/UreYJRT65GStA3+irRL1Ao0pHZwBtCmTc+4prwA=
github.com/Mrs4s/MiraiGo v0.0.0-20200808044635-cd20d7d43dbb/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=