commit
d07800abaf
@ -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
|
|
@ -5,112 +5,112 @@ option go_package = "./wcf";
|
|||||||
option java_package = "com.iamteer";
|
option java_package = "com.iamteer";
|
||||||
|
|
||||||
enum Functions {
|
enum Functions {
|
||||||
FUNC_RESERVED = 0x00;
|
FUNC_RESERVED = 0x00;
|
||||||
FUNC_IS_LOGIN = 0x01;
|
FUNC_IS_LOGIN = 0x01;
|
||||||
FUNC_GET_SELF_WXID = 0x10;
|
FUNC_GET_SELF_WXID = 0x10;
|
||||||
FUNC_GET_MSG_TYPES = 0x11;
|
FUNC_GET_MSG_TYPES = 0x11;
|
||||||
FUNC_GET_CONTACTS = 0x12;
|
FUNC_GET_CONTACTS = 0x12;
|
||||||
FUNC_GET_DB_NAMES = 0x13;
|
FUNC_GET_DB_NAMES = 0x13;
|
||||||
FUNC_GET_DB_TABLES = 0x14;
|
FUNC_GET_DB_TABLES = 0x14;
|
||||||
FUNC_GET_USER_INFO = 0x15;
|
FUNC_GET_USER_INFO = 0x15;
|
||||||
FUNC_SEND_TXT = 0x20;
|
FUNC_SEND_TXT = 0x20;
|
||||||
FUNC_SEND_IMG = 0x21;
|
FUNC_SEND_IMG = 0x21;
|
||||||
FUNC_SEND_FILE = 0x22;
|
FUNC_SEND_FILE = 0x22;
|
||||||
FUNC_SEND_XML = 0x23;
|
FUNC_SEND_XML = 0x23;
|
||||||
FUNC_SEND_EMOTION = 0x24;
|
FUNC_SEND_EMOTION = 0x24;
|
||||||
FUNC_ENABLE_RECV_TXT = 0x30;
|
FUNC_ENABLE_RECV_TXT = 0x30;
|
||||||
FUNC_DISABLE_RECV_TXT = 0x40;
|
FUNC_DISABLE_RECV_TXT = 0x40;
|
||||||
FUNC_EXEC_DB_QUERY = 0x50;
|
FUNC_EXEC_DB_QUERY = 0x50;
|
||||||
FUNC_ACCEPT_FRIEND = 0x51;
|
FUNC_ACCEPT_FRIEND = 0x51;
|
||||||
FUNC_ADD_ROOM_MEMBERS = 0x52;
|
FUNC_ADD_ROOM_MEMBERS = 0x52;
|
||||||
FUNC_RECV_TRANSFER = 0x53;
|
FUNC_RECV_TRANSFER = 0x53;
|
||||||
FUNC_DECRYPT_IMAGE = 0x60;
|
FUNC_DECRYPT_IMAGE = 0x60;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Request
|
message Request
|
||||||
{
|
{
|
||||||
Functions func = 1;
|
Functions func = 1;
|
||||||
oneof msg
|
oneof msg
|
||||||
{
|
{
|
||||||
Empty empty = 2;
|
Empty empty = 2;
|
||||||
string str = 3;
|
string str = 3;
|
||||||
TextMsg txt = 4;
|
TextMsg txt = 4;
|
||||||
PathMsg file = 5;
|
PathMsg file = 5;
|
||||||
DbQuery query = 6;
|
DbQuery query = 6;
|
||||||
Verification v = 7;
|
Verification v = 7;
|
||||||
AddMembers m = 8;
|
AddMembers m = 8;
|
||||||
XmlMsg xml = 9;
|
XmlMsg xml = 9;
|
||||||
DecPath dec = 10;
|
DecPath dec = 10;
|
||||||
Transfer tf = 11;
|
Transfer tf = 11;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message Response
|
message Response
|
||||||
{
|
{
|
||||||
Functions func = 1;
|
Functions func = 1;
|
||||||
oneof msg
|
oneof msg
|
||||||
{
|
{
|
||||||
int32 status = 2; // Int 状态,通用
|
int32 status = 2; // Int 状态,通用
|
||||||
string str = 3; // 字符串
|
string str = 3; // 字符串
|
||||||
WxMsg wxmsg = 4; // 微信消息
|
WxMsg wxmsg = 4; // 微信消息
|
||||||
MsgTypes types = 5; // 消息类型
|
MsgTypes types = 5; // 消息类型
|
||||||
RpcContacts contacts = 6; // 联系人
|
RpcContacts contacts = 6; // 联系人
|
||||||
DbNames dbs = 7; // 数据库列表
|
DbNames dbs = 7; // 数据库列表
|
||||||
DbTables tables = 8; // 表列表
|
DbTables tables = 8; // 表列表
|
||||||
DbRows rows = 9; // 行列表
|
DbRows rows = 9; // 行列表
|
||||||
UserInfo ui = 10; // 个人信息
|
UserInfo ui = 10; // 个人信息
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
message Empty { }
|
message Empty { }
|
||||||
|
|
||||||
message WxMsg
|
message WxMsg
|
||||||
{
|
{
|
||||||
bool is_self = 1; // 是否自己发送的
|
bool is_self = 1; // 是否自己发送的
|
||||||
bool is_group = 2; // 是否群消息
|
bool is_group = 2; // 是否群消息
|
||||||
int32 type = 3; // 消息类型
|
int32 type = 3; // 消息类型
|
||||||
string id = 4; // 消息 id
|
string id = 4; // 消息 id
|
||||||
string xml = 5; // 消息 xml
|
string xml = 5; // 消息 xml
|
||||||
string sender = 6; // 消息发送者
|
string sender = 6; // 消息发送者
|
||||||
string roomid = 7; // 群 id(如果是群消息的话)
|
string roomid = 7; // 群 id(如果是群消息的话)
|
||||||
string content = 8; // 消息内容
|
string content = 8; // 消息内容
|
||||||
string thumb = 9; // 缩略图
|
string thumb = 9; // 缩略图
|
||||||
string extra = 10; // 附加内容
|
string extra = 10; // 附加内容
|
||||||
}
|
}
|
||||||
|
|
||||||
message TextMsg
|
message TextMsg
|
||||||
{
|
{
|
||||||
string msg = 1; // 要发送的消息内容
|
string msg = 1; // 要发送的消息内容
|
||||||
string receiver = 2; // 消息接收人,当为群时可@
|
string receiver = 2; // 消息接收人,当为群时可@
|
||||||
string aters = 3; // 要@的人列表,逗号分隔
|
string aters = 3; // 要@的人列表,逗号分隔
|
||||||
}
|
}
|
||||||
|
|
||||||
message PathMsg
|
message PathMsg
|
||||||
{
|
{
|
||||||
string path = 1; // 要发送的图片的路径
|
string path = 1; // 要发送的图片的路径
|
||||||
string receiver = 2; // 消息接收人
|
string receiver = 2; // 消息接收人
|
||||||
}
|
}
|
||||||
|
|
||||||
message XmlMsg
|
message XmlMsg
|
||||||
{
|
{
|
||||||
string receiver = 1; // 消息接收人
|
string receiver = 1; // 消息接收人
|
||||||
string content = 2; // xml 内容
|
string content = 2; // xml 内容
|
||||||
string path = 3; // 图片路径
|
string path = 3; // 图片路径
|
||||||
int32 type = 4; // 消息类型
|
int32 type = 4; // 消息类型
|
||||||
}
|
}
|
||||||
|
|
||||||
message MsgTypes { map<int32, string> types = 1; }
|
message MsgTypes { map<int32, string> types = 1; }
|
||||||
|
|
||||||
message RpcContact
|
message RpcContact
|
||||||
{
|
{
|
||||||
string wxid = 1; // 微信 id
|
string wxid = 1; // 微信 id
|
||||||
string code = 2; // 微信号
|
string code = 2; // 微信号
|
||||||
string remark = 3; // 备注
|
string remark = 3; // 备注
|
||||||
string name = 4; // 微信昵称
|
string name = 4; // 微信昵称
|
||||||
string country = 5; // 国家
|
string country = 5; // 国家
|
||||||
string province = 6; // 省/州
|
string province = 6; // 省/州
|
||||||
string city = 7; // 城市
|
string city = 7; // 城市
|
||||||
int32 gender = 8; // 性别
|
int32 gender = 8; // 性别
|
||||||
}
|
}
|
||||||
message RpcContacts { repeated RpcContact contacts = 1; }
|
message RpcContacts { repeated RpcContact contacts = 1; }
|
||||||
|
|
||||||
@ -118,54 +118,55 @@ message DbNames { repeated string names = 1; }
|
|||||||
|
|
||||||
message DbTable
|
message DbTable
|
||||||
{
|
{
|
||||||
string name = 1; // 表名
|
string name = 1; // 表名
|
||||||
string sql = 2; // 建表 SQL
|
string sql = 2; // 建表 SQL
|
||||||
}
|
}
|
||||||
message DbTables { repeated DbTable tables = 1; }
|
message DbTables { repeated DbTable tables = 1; }
|
||||||
|
|
||||||
message DbQuery
|
message DbQuery
|
||||||
{
|
{
|
||||||
string db = 1; // 目标数据库
|
string db = 1; // 目标数据库
|
||||||
string sql = 2; // 查询 SQL
|
string sql = 2; // 查询 SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
message DbField
|
message DbField
|
||||||
{
|
{
|
||||||
int32 type = 1; // 字段类型
|
int32 type = 1; // 字段类型
|
||||||
string column = 2; // 字段名称
|
string column = 2; // 字段名称
|
||||||
bytes content = 3; // 字段内容
|
bytes content = 3; // 字段内容
|
||||||
}
|
}
|
||||||
message DbRow { repeated DbField fields = 1; }
|
message DbRow { repeated DbField fields = 1; }
|
||||||
message DbRows { repeated DbRow rows = 1; }
|
message DbRows { repeated DbRow rows = 1; }
|
||||||
|
|
||||||
message Verification
|
message Verification
|
||||||
{
|
{
|
||||||
string v3 = 1;
|
string v3 = 1; // 加密的用户名
|
||||||
string v4 = 2;
|
string v4 = 2; // Ticket
|
||||||
|
int32 scene = 3; // 添加方式:17 名片,30 扫码
|
||||||
}
|
}
|
||||||
|
|
||||||
message AddMembers
|
message AddMembers
|
||||||
{
|
{
|
||||||
string roomid = 1; // 要加的群ID
|
string roomid = 1; // 要加的群ID
|
||||||
string wxids = 2; // 要加群的人列表,逗号分隔
|
string wxids = 2; // 要加群的人列表,逗号分隔
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserInfo
|
message UserInfo
|
||||||
{
|
{
|
||||||
string wxid = 1; // 微信ID
|
string wxid = 1; // 微信ID
|
||||||
string name = 2; // 昵称
|
string name = 2; // 昵称
|
||||||
string mobile = 3; // 手机号
|
string mobile = 3; // 手机号
|
||||||
string home = 4; // 文件/图片等父路径
|
string home = 4; // 文件/图片等父路径
|
||||||
}
|
}
|
||||||
|
|
||||||
message DecPath
|
message DecPath
|
||||||
{
|
{
|
||||||
string src = 1; // 源路径
|
string src = 1; // 源路径
|
||||||
string dst = 2; // 目标路径
|
string dst = 2; // 目标路径
|
||||||
}
|
}
|
||||||
|
|
||||||
message Transfer
|
message Transfer
|
||||||
{
|
{
|
||||||
string wxid = 1; // 转账人
|
string wxid = 1; // 转账人
|
||||||
string tid = 2; // 转账id transferid
|
string tid = 2; // 转账id transferid
|
||||||
}
|
}
|
||||||
|
@ -132,8 +132,25 @@ func (c *Client) ExecDBQuery(db, sql string) []*DbRow {
|
|||||||
}
|
}
|
||||||
return recv.GetRows().GetRows()
|
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 {
|
if err != nil {
|
||||||
logs.Err(err)
|
logs.Err(err)
|
||||||
}
|
}
|
||||||
@ -143,6 +160,59 @@ func (c *Client) AcceptFriend() int32 {
|
|||||||
}
|
}
|
||||||
return recv.GetStatus()
|
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 {
|
func (c *Client) AddChatRoomMembers(roomId string, wxIds []string) int32 {
|
||||||
req := genFunReq(Functions_FUNC_ADD_ROOM_MEMBERS)
|
req := genFunReq(Functions_FUNC_ADD_ROOM_MEMBERS)
|
||||||
q := Request_M{
|
q := Request_M{
|
||||||
@ -292,8 +362,8 @@ func (c *Client) OnMSG(f func(msg *WxMsg)) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
socket.SetOption(mangos.OptionRecvDeadline, 2000)
|
_ = socket.SetOption(mangos.OptionRecvDeadline, 2000)
|
||||||
socket.SetOption(mangos.OptionSendDeadline, 2000)
|
_ = socket.SetOption(mangos.OptionSendDeadline, 2000)
|
||||||
err = socket.Dial(addPort(c.add))
|
err = socket.Dial(addPort(c.add))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -305,7 +375,6 @@ func (c *Client) OnMSG(f func(msg *WxMsg)) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logs.Info(len(recv))
|
|
||||||
_ = proto.Unmarshal(recv, msg)
|
_ = proto.Unmarshal(recv, msg)
|
||||||
go f(msg.GetWxmsg())
|
go f(msg.GetWxmsg())
|
||||||
}
|
}
|
||||||
|
596
go/wcf/wcf.pb.go
596
go/wcf/wcf.pb.go
File diff suppressed because it is too large
Load Diff
@ -112,7 +112,7 @@ func TestAcceptFriend(t *testing.T) {
|
|||||||
logs.Err(err)
|
logs.Err(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logs.Info(wcf.AcceptFriend())
|
logs.Info(wcf.AcceptFriend("encryptusername", "ticket", 17))
|
||||||
}
|
}
|
||||||
func TestGetUserInfo(t *testing.T) {
|
func TestGetUserInfo(t *testing.T) {
|
||||||
wcf, err := NewWCF("")
|
wcf, err := NewWCF("")
|
||||||
|
Loading…
Reference in New Issue
Block a user