Skip to content

Commit

Permalink
feat: Implemented poke
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan04 committed Apr 20, 2024
1 parent 612a50e commit d76ed6b
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
40 changes: 40 additions & 0 deletions client/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,43 @@ func (c *QQClient) GroupSetSpecialTitle(groupUin, uin uint32, title string) erro

return nil
}

func (c *QQClient) GroupPoke(groupID, uin uint32) error {
pkt, err := oidb.BuildGroupPokeReq(groupID, uin)
if err != nil {
return err
}
resp, err := c.SendOidbPacketAndWait(pkt)
if err != nil {
return err
}
ok, err := oidb.ParsePokeResp(resp.Data)
if err != nil {
return err
}
if !ok {
return errors.New("poke failed")
}

return nil
}

func (c *QQClient) FriendPoke(uin uint32) error {
pkt, err := oidb.BuildFriendPokeReq(uin)
if err != nil {
return err
}
resp, err := c.SendOidbPacketAndWait(pkt)
if err != nil {
return err
}
ok, err := oidb.ParsePokeResp(resp.Data)
if err != nil {
return err
}
if !ok {
return errors.New("poke failed")
}

return nil
}
36 changes: 36 additions & 0 deletions packets/oidb/Poke.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package oidb

import (
"errors"
"github.com/LagrangeDev/LagrangeGo/packets/pb/service/oidb"
"github.com/RomiChan/protobuf/proto"
)

func BuildGroupPokeReq(groupUin, uin uint32) (*OidbPacket, error) {
body := &oidb.OidbSvcTrpcTcp0XED3_1{
Uin: uin,
GroupUin: groupUin,
Ext: proto.Some[uint32](1),
}
return BuildOidbPacket(0xED3, 1, body, false, false)
}

func BuildFriendPokeReq(uin uint32) (*OidbPacket, error) {
body := &oidb.OidbSvcTrpcTcp0XED3_1{
Uin: uin,
FriendUin: uin,
Ext: proto.Some[uint32](1),
}
return BuildOidbPacket(0xED3, 1, body, false, false)
}

func ParsePokeResp(data []byte) (bool, error) {
baseResp, err := ParseOidbPacket(data, nil)
if err != nil {
return false, err
}
if baseResp.ErrorCode != 0 {
return false, errors.New(baseResp.ErrorMsg)
}
return true, nil
}
1 change: 1 addition & 0 deletions sig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Sequence":8901,"Tgtgt":"BCCgSr6jXSS152VX5gzPBg==","Tgt":"ZwhpAHI0+IXnOyM7aWaI3pDfv+bG6d5fcstsiv+vVf5rc0hLYe7gn+lQZqKthqxUSnzn7+yr+dFDaXXKAV3DBOGCObNyA7OZ","D2":"6Eh025S5eIYgXBjgjHNux4g3dGUlQ6Qyypk2OOTVScgd8s/tZp3Mn0ShgsGUP6ohRSIwqZ/xt2JhzoNPjfoLRdvv8hc4e9YVxGCdc5R6BqlIZCfzVMB1gA==","D2Key":"NCw0QlZTOz8ocyhhJGcrZQ==","Qrsig":"KR3P4aJXvxWdcLD4kqqlKUmYo0yuTKEt","ExchangeKey":"1koG+MOC7P4pmDUj6mSmdhFG5QY0Y3gvNdxJemI35OM=","KeySig":"fj/L9A1bgXBhqB4Iqr5J93WeI/lDA+7T0I/OlBRqUsUlHfcFkRpdtU17xRb3jCM39uKUOHHNagPdY0IN1wTPmXdB8usSCyOorDF9iIfgi74hKaKfRwxhIOzpkkjhx7TX5Vtkqk8H1OQ=","Cookies":"","UnusualSig":"","TempPwd":"xDR7IgZSkKRTCq8qu4x5wAWmnQHsEtl7mDNADqdJ5StFll5LLWumxfpFgh8s6CbZmIu4iHuRV2OTCrkWyehkZj7VMnJaP040VhRs890kNxOuekyKNhAt7XgCIT65TmI+zgNvFEC7WWfVYtYaxO559aU6QAug8YaUzjRU/u8n17jL991BWiyBRjJ7IQq6eGBuutCHHM2Q/nM=","Uid":"u_T0WhBZchiZhEUIbSxoocGA","CaptchaInfo":["","",""]}

0 comments on commit d76ed6b

Please sign in to comment.