Skip to content

Commit 6b1e913

Browse files
committed
api: get cookies
1 parent 54b8712 commit 6b1e913

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/smartystreets/goconvey v1.6.4 // indirect
1818
github.com/ugorji/go v1.2.5 // indirect
1919
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
20-
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 // indirect
20+
golang.org/x/sys v0.0.0-20210402192133-700132347e07 // indirect
2121
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
2222
gopkg.in/yaml.v2 v2.4.0 // indirect
2323
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ golang.org/x/sys v0.0.0-20210324051608-47abb6519492 h1:Paq34FxTluEPvVyayQqMPgHm+
130130
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
131131
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 h1:rF3Ohx8DRyl8h2zw9qojyLHLhrJpEMgyPOImREEryf0=
132132
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
133+
golang.org/x/sys v0.0.0-20210402192133-700132347e07 h1:4k6HsQjxj6hVMsI2Vf0yKlzt5lXxZsMW1q0zaq2k8zY=
134+
golang.org/x/sys v0.0.0-20210402192133-700132347e07/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
133135
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
134136
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
135137
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=

service/bot/api_handler.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"math"
66
"strconv"
7+
_ "unsafe"
78

89
"github.com/Mrs4s/MiraiGo/client"
910
"github.com/Mrs4s/MiraiGo/message"
@@ -521,3 +522,10 @@ func HandleGetStrangerInfo(cli *client.QQClient, req *onebot.GetStrangerInfoReq)
521522
LoginDays: info.LoginDays,
522523
}
523524
}
525+
526+
//go:linkname GetCookiesWithDomain github.com/Mrs4s/MiraiGo/client.(*QQClient).getCookiesWithDomain
527+
func GetCookiesWithDomain(c *client.QQClient, domain string) string
528+
529+
func HandleGetCookies(cli *client.QQClient, req *onebot.GetCookiesReq) *onebot.GetCookiesResp {
530+
return &onebot.GetCookiesResp{Cookies: GetCookiesWithDomain(cli, req.Domain)}
531+
}

service/bot/api_handler.s

Whitespace-only changes.

service/bot/remote.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ func handleApiFrame(cli *client.QQClient, req *onebot.Frame) *onebot.Frame {
228228
resp.Data = &onebot.Frame_GetStrangerInfoResp{
229229
GetStrangerInfoResp: HandleGetStrangerInfo(cli, data.GetStrangerInfoReq),
230230
}
231+
case *onebot.Frame_GetCookiesReq:
232+
resp.FrameType = onebot.Frame_TGetCookiesResp
233+
resp.Data = &onebot.Frame_GetCookiesResp{
234+
GetCookiesResp: HandleGetCookies(cli, data.GetCookiesReq),
235+
}
231236
default:
232237
return resp
233238
}

0 commit comments

Comments
 (0)