Skip to content

Commit 3a61ff7

Browse files
committed
fix video url
1 parent 469736b commit 3a61ff7

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module github.com/ProtobufBot/Go-Mirai-Client
33
go 1.16
44

55
require (
6-
github.com/Mrs4s/MiraiGo v0.0.0-20210611062429-4f967b0a6264
6+
github.com/Mrs4s/MiraiGo v0.0.0-20210712050404-061067bf955c
77
github.com/fanliao/go-promise v0.0.0-20141029170127-1890db352a72
88
github.com/gin-gonic/gin v1.7.2
9-
github.com/go-playground/validator/v10 v10.6.1 // indirect
9+
github.com/go-playground/validator/v10 v10.7.0 // indirect
1010
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
1111
github.com/golang/protobuf v1.5.2
1212
github.com/gorilla/websocket v1.4.2
@@ -18,11 +18,11 @@ require (
1818
github.com/sirupsen/logrus v1.8.1
1919
github.com/smartystreets/goconvey v1.6.4 // indirect
2020
github.com/ugorji/go v1.2.6 // indirect
21-
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
22-
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
21+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
22+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
2323
golang.org/x/text v0.3.6 // indirect
2424
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
25-
google.golang.org/protobuf v1.27.0 // indirect
25+
google.golang.org/protobuf v1.27.1 // indirect
2626
gopkg.in/yaml.v2 v2.4.0 // indirect
2727
)
2828

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
22
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
33
github.com/Mrs4s/MiraiGo v0.0.0-20210611062429-4f967b0a6264 h1:ltClzJPv4kymlnlSVrquxcHAwYF7HE/76hWhlXCiSEc=
44
github.com/Mrs4s/MiraiGo v0.0.0-20210611062429-4f967b0a6264/go.mod h1:CPaznIPn415uQqxJgjyMHLqGLkvLS6R6+bkW3/fe08Q=
5+
github.com/Mrs4s/MiraiGo v0.0.0-20210712050404-061067bf955c h1:qAV8TEnfFRM6a3tZ/PBeR25RFP3t7GmEJtwGRlxBJcM=
6+
github.com/Mrs4s/MiraiGo v0.0.0-20210712050404-061067bf955c/go.mod h1:CPaznIPn415uQqxJgjyMHLqGLkvLS6R6+bkW3/fe08Q=
57
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
68
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
79
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -24,6 +26,8 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+
2426
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
2527
github.com/go-playground/validator/v10 v10.6.1 h1:W6TRDXt4WcWp4c4nf/G+6BkGdhiIo0k417gfr+V6u4I=
2628
github.com/go-playground/validator/v10 v10.6.1/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk=
29+
github.com/go-playground/validator/v10 v10.7.0 h1:gLi5ajTBBheLNt0ctewgq7eolXoDALQd5/y90Hh9ZgM=
30+
github.com/go-playground/validator/v10 v10.7.0/go.mod h1:xm76BBt941f7yWdGnI2DVPFFg1UK3YY04qifoXU3lOk=
2731
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
2832
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
2933
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -97,6 +101,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
97101
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
98102
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e h1:gsTQYXdTw2Gq7RBsWvlQ91b+aEQ6bXFUngBGuR8sPpI=
99103
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
104+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
105+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
100106
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
101107
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
102108
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@@ -120,6 +126,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
120126
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
121127
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
122128
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
129+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
130+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
123131
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
124132
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
125133
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
@@ -155,6 +163,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
155163
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
156164
google.golang.org/protobuf v1.27.0 h1:KhgSLlr/moiqjv0qUsSnLvdUL7NH7PHW8aZGn7Jpjko=
157165
google.golang.org/protobuf v1.27.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
166+
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
167+
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
158168
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
159169
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
160170
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

service/bot/api_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func HandleGetMsg(cli *client.QQClient, req *onebot.GetMsgReq) *onebot.GetMsgRes
246246
MessageType: messageType,
247247
MessageId: req.MessageId,
248248
RealId: event.InternalId, // 不知道是什么?
249-
Message: MiraiMsgToProtoMsg(event.Elements),
249+
Message: MiraiMsgToProtoMsg(cli, event.Elements),
250250
RawMessage: MiraiMsgToRawMsg(event.Elements),
251251
Sender: &onebot.GetMsgResp_Sender{
252252
UserId: event.Sender.Uin,
@@ -267,7 +267,7 @@ func HandleGetMsg(cli *client.QQClient, req *onebot.GetMsgReq) *onebot.GetMsgRes
267267
MessageType: messageType,
268268
MessageId: req.MessageId,
269269
RealId: event.InternalId, // 不知道是什么?
270-
Message: MiraiMsgToProtoMsg(event.Elements),
270+
Message: MiraiMsgToProtoMsg(cli, event.Elements),
271271
RawMessage: MiraiMsgToRawMsg(event.Elements),
272272
Sender: &onebot.GetMsgResp_Sender{
273273
UserId: event.Sender.Uin,

service/bot/mirai2proto.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package bot
33
import (
44
"strconv"
55

6+
"github.com/Mrs4s/MiraiGo/client"
67
"github.com/Mrs4s/MiraiGo/message"
78
"github.com/ProtobufBot/Go-Mirai-Client/proto_gen/onebot"
89
)
910

10-
func MiraiMsgToProtoMsg(messageChain []message.IMessageElement) []*onebot.Message {
11+
func MiraiMsgToProtoMsg(cli *client.QQClient, messageChain []message.IMessageElement) []*onebot.Message {
1112
msgList := make([]*onebot.Message, 0)
1213
for _, element := range messageChain {
1314
switch elem := element.(type) {
@@ -26,7 +27,7 @@ func MiraiMsgToProtoMsg(messageChain []message.IMessageElement) []*onebot.Messag
2627
case *message.LightAppElement:
2728
msgList = append(msgList, MiraiLightAppToProtoLightApp(elem))
2829
case *message.ShortVideoElement:
29-
msgList = append(msgList, MiraiVideoToProtoVideo(elem))
30+
msgList = append(msgList, MiraiVideoToProtoVideo(cli, elem))
3031
case *message.ReplyElement:
3132
msgList = append(msgList, MiraiReplyToProtoReply(elem))
3233
}
@@ -107,12 +108,12 @@ func MiraiLightAppToProtoLightApp(elem *message.LightAppElement) *onebot.Message
107108
}
108109
}
109110

110-
func MiraiVideoToProtoVideo(elem *message.ShortVideoElement) *onebot.Message {
111+
func MiraiVideoToProtoVideo(cli *client.QQClient, elem *message.ShortVideoElement) *onebot.Message {
111112
return &onebot.Message{
112113
Type: "video",
113114
Data: map[string]string{
114115
"name": elem.Name,
115-
"url": elem.Url,
116+
"url": cli.GetShortVideoUrl(elem.Uuid, elem.Md5),
116117
},
117118
}
118119
}

service/plugins/report.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func ReportPrivateMessage(cli *client.QQClient, event *message.PrivateMessage) i
2929
SubType: "normal",
3030
MessageId: event.Id,
3131
UserId: event.Sender.Uin,
32-
Message: bot.MiraiMsgToProtoMsg(event.Elements),
32+
Message: bot.MiraiMsgToProtoMsg(cli, event.Elements),
3333
RawMessage: bot.MiraiMsgToRawMsg(event.Elements),
3434
Sender: &onebot.PrivateMessageEvent_Sender{
3535
UserId: event.Sender.Uin,
@@ -58,7 +58,7 @@ func ReportGroupMessage(cli *client.QQClient, event *message.GroupMessage) int32
5858
MessageId: event.Id,
5959
GroupId: event.GroupCode,
6060
UserId: event.Sender.Uin,
61-
Message: bot.MiraiMsgToProtoMsg(event.Elements),
61+
Message: bot.MiraiMsgToProtoMsg(cli, event.Elements),
6262
RawMessage: bot.MiraiMsgToRawMsg(event.Elements),
6363
Sender: &onebot.GroupMessageEvent_Sender{
6464
UserId: event.Sender.Uin,
@@ -149,7 +149,7 @@ func ReportTempMessage(cli *client.QQClient, event *client.TempMessageEvent) int
149149
SubType: "group",
150150
MessageId: event.Message.Id,
151151
UserId: event.Message.Sender.Uin,
152-
Message: bot.MiraiMsgToProtoMsg(event.Message.Elements),
152+
Message: bot.MiraiMsgToProtoMsg(cli, event.Message.Elements),
153153
RawMessage: bot.MiraiMsgToRawMsg(event.Message.Elements),
154154
Sender: &onebot.PrivateMessageEvent_Sender{
155155
UserId: event.Message.Sender.Uin,

0 commit comments

Comments
 (0)