Merge pull request #24 from danbai225/master

接受好友申请
This commit is contained in:
Changhua 2023-05-07 12:09:00 +08:00 committed by GitHub
commit d07800abaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 472 additions and 401 deletions

View File

@ -1,9 +0,0 @@
# Generate all fields as pointers.
* mangle_names:M_STRIP_PACKAGE
* fallback_type:FT_POINTER
MsgTypes* fallback_type:FT_CALLBACK
RpcContact* fallback_type:FT_CALLBACK
DbNames* fallback_type:FT_CALLBACK
DbTable* fallback_type:FT_CALLBACK
DbField* fallback_type:FT_CALLBACK
DbRow* fallback_type:FT_CALLBACK

View File

@ -140,8 +140,9 @@ message DbRows { repeated DbRow rows = 1; }
message Verification
{
string v3 = 1;
string v4 = 2;
string v3 = 1; //
string v4 = 2; // Ticket
int32 scene = 3; // 17 30
}
message AddMembers

View File

@ -132,8 +132,25 @@ func (c *Client) ExecDBQuery(db, sql string) []*DbRow {
}
return recv.GetRows().GetRows()
}
func (c *Client) AcceptFriend() int32 {
err := c.send(genFunReq(Functions_FUNC_ACCEPT_FRIEND).build())
/*AcceptFriend 接收好友请求
* 接收好友请求
*
* @param v3 xml.attrib["encryptusername"] // 加密的用户名
* @param v4 xml.attrib["ticket"] // Ticket
* @param scene 17 // 添加方式17 名片30 扫码
*/
func (c *Client) AcceptFriend(v3, v4 string, scene int32) int32 {
req := genFunReq(Functions_FUNC_ACCEPT_FRIEND)
q := Request_V{
V: &Verification{
V3: v3,
V4: v4,
Scene: scene,
}}
req.Msg = &q
err := c.send(req.build())
if err != nil {
logs.Err(err)
}
@ -143,6 +160,59 @@ func (c *Client) AcceptFriend() int32 {
}
return recv.GetStatus()
}
func (c *Client) AddChatroomMembers(roomID, wxIDs string) int32 {
req := genFunReq(Functions_FUNC_ADD_ROOM_MEMBERS)
q := Request_M{
M: &AddMembers{Roomid: roomID, Wxids: wxIDs},
}
req.Msg = &q
err := c.send(req.build())
if err != nil {
logs.Err(err)
}
recv, err := c.Recv()
if err != nil {
logs.Err(err)
}
return recv.GetStatus()
}
// ReceiveTransfer 接收转账
func (c *Client) ReceiveTransfer(transferId, wxID string) int32 {
req := genFunReq(Functions_FUNC_RECV_TRANSFER)
q := Request_Tf{
Tf: &Transfer{Tid: transferId, Wxid: wxID},
}
req.Msg = &q
err := c.send(req.build())
if err != nil {
logs.Err(err)
}
recv, err := c.Recv()
if err != nil {
logs.Err(err)
}
return recv.GetStatus()
}
// DecryptImage 解密图片 加密路径,解密路径
func (c *Client) DecryptImage(src, dst string) int32 {
req := genFunReq(Functions_FUNC_DECRYPT_IMAGE)
q := Request_Dec{
Dec: &DecPath{Src: src, Dst: dst},
}
req.Msg = &q
err := c.send(req.build())
if err != nil {
logs.Err(err)
}
recv, err := c.Recv()
if err != nil {
logs.Err(err)
}
return recv.GetStatus()
}
func (c *Client) AddChatRoomMembers(roomId string, wxIds []string) int32 {
req := genFunReq(Functions_FUNC_ADD_ROOM_MEMBERS)
q := Request_M{
@ -292,8 +362,8 @@ func (c *Client) OnMSG(f func(msg *WxMsg)) error {
if err != nil {
return err
}
socket.SetOption(mangos.OptionRecvDeadline, 2000)
socket.SetOption(mangos.OptionSendDeadline, 2000)
_ = socket.SetOption(mangos.OptionRecvDeadline, 2000)
_ = socket.SetOption(mangos.OptionSendDeadline, 2000)
err = socket.Dial(addPort(c.add))
if err != nil {
@ -305,7 +375,6 @@ func (c *Client) OnMSG(f func(msg *WxMsg)) error {
if err != nil {
return err
}
logs.Info(len(recv))
_ = proto.Unmarshal(recv, msg)
go f(msg.GetWxmsg())
}

File diff suppressed because it is too large Load Diff

View File

@ -112,7 +112,7 @@ func TestAcceptFriend(t *testing.T) {
logs.Err(err)
return
}
logs.Info(wcf.AcceptFriend())
logs.Info(wcf.AcceptFriend("encryptusername", "ticket", 17))
}
func TestGetUserInfo(t *testing.T) {
wcf, err := NewWCF("")