Skip to content

Commit

Permalink
这倒霉玩意(╯‵□′)╯︵┻━┻
Browse files Browse the repository at this point in the history
  • Loading branch information
icarus-ai committed Nov 14, 2024
1 parent e95f6aa commit 252319a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions client/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1337,14 +1337,14 @@ func (c *QQClient) DeleteUnidirectionalFriend(uin uint32) error {
}

// CheckUrlSafely 通过TX服务器检查URL安全性
func (c *QQClient) CheckUrlSafely(url string) (oidb2.UrlSecurityLevel, error) {
func (c *QQClient) CheckUrlSafely(url string) (oidb2.URLSecurityLevel, error) {

Check failure on line 1340 in client/operation.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: method CheckUrlSafely should be CheckURLSafely (revive)
pkt, err := oidb2.BuildUrlCheckRequest(c.Uin, url)
if err != nil {
return oidb2.UrlSecurityLevelUnknown, err
return oidb2.URLSecurityLevelUnknown, err
}
resp, err := c.sendOidbPacketAndWait(pkt)
if err != nil {
return oidb2.UrlSecurityLevelUnknown, err
return oidb2.URLSecurityLevelUnknown, err
}
return oidb2.ParseUrlCheckResponse(resp)
}
26 changes: 13 additions & 13 deletions client/packets/oidb/security_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (

// see https://github.com/Mrs4s/MiraiGo/blob/master/client/security.go

type UrlSecurityLevel int
type URLSecurityLevel int

const (
UrlSecurityLevelSafe UrlSecurityLevel = iota + 1
UrlSecurityLevelUnknown
UrlSecurityLevelDanger
URLSecurityLevelSafe URLSecurityLevel = iota + 1
URLSecurityLevelUnknown
URLSecurityLevelDanger
)

func (m UrlSecurityLevel) String() string {
func (m URLSecurityLevel) String() string {
switch m {

Check failure on line 22 in client/packets/oidb/security_url.go

View workflow job for this annotation

GitHub Actions / lint

missing cases in switch of type oidb.URLSecurityLevel: oidb.URLSecurityLevelUnknown (exhaustive)
case UrlSecurityLevelSafe:
case URLSecurityLevelSafe:
return "safe"
case UrlSecurityLevelDanger:
case URLSecurityLevelDanger:
return "danger"
default:
return "unknown"
Expand All @@ -48,20 +48,20 @@ func BuildUrlCheckRequest(botuin uint32, url string) (*Packet, error) {
return BuildOidbPacket(0xBCB, 0, body, false, false)
}

func ParseUrlCheckResponse(data []byte) (UrlSecurityLevel, error) {
func ParseUrlCheckResponse(data []byte) (URLSecurityLevel, error) {

Check failure on line 51 in client/packets/oidb/security_url.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: func ParseUrlCheckResponse should be ParseURLCheckResponse (revive)
var rsp oidb.OidbSvcTrpcTcp0XBCB_0_RspBody
_, err := ParseOidbPacket(data, &rsp)
if err != nil {
return UrlSecurityLevelUnknown, err
return URLSecurityLevelUnknown, err
}
if rsp.CheckUrlRsp == nil || len(rsp.CheckUrlRsp.Results) == 0 {
return UrlSecurityLevelUnknown, errors.New("response is empty")
return URLSecurityLevelUnknown, errors.New("response is empty")
}
if rsp.CheckUrlRsp.Results[0].JumpUrl.IsSome() {
return UrlSecurityLevelDanger, nil
return URLSecurityLevelDanger, nil
}
if rsp.CheckUrlRsp.Results[0].Umrtype.Unwrap() == 2 {
return UrlSecurityLevelSafe, nil
return URLSecurityLevelSafe, nil
}
return UrlSecurityLevelUnknown, nil
return URLSecurityLevelUnknown, nil
}

0 comments on commit 252319a

Please sign in to comment.