Exemple #1
0
        public static API.GroupWithdrawInfo SendGroupAudio(byte[] BytesIn, byte[] filekey)
        {
            var timestamp = long.Parse(Convert.ToInt64(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds).ToString().Substring(0, 10));
            List <SendMessages> MsgList = new List <SendMessages>();

            BytesIn = BytesIn.Skip(4).ToArray();
            using (var ms = new MemoryStream(BytesIn))
            {
                var result            = Serializer.Deserialize <GroupAudioHashStruct>(ms);
                var sAddr             = API.Int32ToIP(result.GroupAudioHashInfo.IP);
                var Port              = result.GroupAudioHashInfo.Port;
                var uKey              = result.GroupAudioHashInfo.ukey;
                var token             = result.GroupAudioHashInfo.token;
                SendGroupMsgInfos msg = new SendGroupMsgInfos
                {
                    SendGroupMsg = new SendGroupMsgs
                    {
                        SendGroupAudioInfo = new SendGroupAudioInfos
                        {
                            Field1 = 4, AudioHash = filekey, AudioName = BitConverter.ToString(filekey).Replace("-", "") + ".amr", AudioSize = 4590, uKey = new byte[] { 0x16, 0x36, 0x20, 0x38, 0x36, 0x65, 0x41, 0x31, 0x4, 0x34, 0x38, 0x36, 0x34, 0x63, 0x32, 0x33, 0x63, 0x62, 0x34, 0x61, 0x33, 0x31, 0x36, 0x31, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x35, 0x30, 0x1A, 0x88, 0xF9, 0x2C, 0x88, 0x4D, 0xB1, 0xF5, 0xC, 0xB1, 0x5B, 0x33, 0xF8, 0xFA, 0x10, 0x6D, 0x31, 0x41, 0x38, 0x38, 0x46, 0x39, 0x32, 0x43, 0x38, 0x38, 0x34, 0x44, 0x42, 0x31, 0x46, 0x35, 0x30, 0x43, 0x42, 0x31, 0x35, 0x42, 0x33, 0x33, 0x46, 0x38, 0x46, 0x41, 0x31, 0x30, 0x36, 0x44, 0x2E, 0x61, 0x6D, 0x72, 0x41 },
                            IP     = 1214562876, Field9 = 3030586896, Port = 80, Field11 = 1, token = token, Field19 = 0, AudioUrl = "/?ver=0&rkey=3062020101045b3059020101020101020416525dfe042439306a33676f4e4551795062466248363843666238536b49525067497264332357336872020457f8edde041f0000000866696c6574797065000000013100000005636f64656300000001310400&filetype=1&voice_codec=1", Field29 = 1, Field30 = new AudioUnKnownInfos {
                                Field1 = 0
                            }
                        }
                    }
                };

                SendGroupMsgStuct SendGroupMessage = new SendGroupMsgStuct
                {
                    GroupInformation = new GroupInformations
                    {
                        GroupFrom = new GroupFroms {
                            GroupId = API.GroupId
                        }
                    },
                    GroupMsgId       = new byte[] { 8, 1, 0x10, 0, 0x18, 0 },
                    SendGroupMsgInfo = msg,
                    MsgReqId         = API.QQ.mRequestID,
                    MsgRandomId      = 0x10000000 + API.QQ.mRequestID,
                    Groupcount       = 1
                };
                API.GroupWithdraw.MsgReqId    = API.QQ.mRequestID;
                API.GroupWithdraw.MsgRandomId = SendGroupMessage.MsgRandomId;
                using (var mStream = new MemoryStream())
                {
                    Serializer.Serialize(mStream, SendGroupMessage);
                    Debug.Print("发送群语音消息:" + mStream.ToArray().Length.ToString() + "\r\n" + BitConverter.ToString(mStream.ToArray()).Replace("-", " "));
                    var SendBytes = API.PackCmdHeader("MessageSvc.PbSendMsg", mStream.ToArray());
                    API.TClient.SendData(API.PackAllHeader(SendBytes));
                }

                //上传群语音
                //var url = "http://" + sAddr + "/?ver=4679&ukey=" + BitConverter.ToString(uKey).Replace("-", "") + "&filekey=" + BitConverter.ToString(filekey).Replace("-", "") + "&filesize=" + fileSize.ToString() + "&range=0&bmd5=" + BitConverter.ToString(filekey).Replace("-", "") + "&mType=pttGu&Audio_codec=1";
                //Dictionary<string, object> Headerdics = new Dictionary<string, object>()
                //{
                //	{"Accept-Encoding", "identity"},
                //	{"User-Agent", "Dalvik/2.1.0 (Linux; U; Android 5.0; SM-G9009D Build/LRX21T"},
                //	{"Content-Type", "application/x-www-form-urlencoded"},
                //	{"Host", sAddr}
                //};
                //var res = HttpClientPostAsync2(url, Headerdics, fileByte, "application/x-www-form-urlencoded", mycookiecontainer, RedirectUrl).Result;
            }

            return(API.GroupWithdraw);
        }
Exemple #2
0
        public static API.GroupWithdrawInfo SendGroupMsg(long thisQQ, long GroupId, byte[] MsgBytes, API.MsgType MsgTypes, long sendQQ = 0)
        {
            byte[] bytes = null;

            var timestamp = long.Parse(Convert.ToInt64(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds).ToString().Substring(0, 10));
            List <SendMessages> MsgList = new List <SendMessages>();

            if (MsgTypes == API.MsgType.TextMsg)             //文字消息
            {
                SendMessages MsgListStruct = new SendMessages
                {
                    SendContent = new SendContents {
                        Content = Encoding.UTF8.GetString(MsgBytes)
                    }
                };
                if (sendQQ != 0)
                {
                    SendMessages MsgListAtStruct = new SendMessages
                    {
                        SendContent = new SendContents
                        {
                            Content = "@" + sendQQ.ToString(),
                            AtHash  = new byte[] { 0x0, 0x1, 0x0, 0x0, 0x0, 0x4, 0x0, 0x2, 0x3B, 0xD7, 0x86, 0x0, 0x0 }
                        }
                    };
                    MsgList.Add(MsgListAtStruct);
                }

                MsgList.Add(MsgListStruct);
            }
            else if (MsgTypes == API.MsgType.XmlMsg)
            {
                SendMessages MsgListStruct = new SendMessages
                {
                    GroupXmlMsg = new GroupXmlContents
                    {
                        Content = MsgBytes,
                        flag    = 1
                    }
                };

                SendMessages XmlFlagStruct = new SendMessages
                {
                    GroupXmlFlag = new GroupXmlFlags {
                        BuddleID = (new Random()).Next(1000001, 1000037)
                    }
                };
                MsgList.Add(MsgListStruct);
                MsgList.Add(XmlFlagStruct);
            }
            else if (MsgTypes == API.MsgType.PicMsg)             //图片消息
            {
                MsgBytes = MsgBytes.Skip(4).ToArray();
                using (var ms = new MemoryStream(MsgBytes))
                {
                    var result = Serializer.Deserialize <GroupPicGuidStruct>(ms);
                    if (result.GroupPicGuidInfo.uKey != null)                     //'服务器没有该图片的hash
                    {
                        var uKey = result.GroupPicGuidInfo.uKey;
                        var Ip   = API.Int32ToIP(result.GroupPicGuidInfo.Ip[0]);
                        var Port = result.GroupPicGuidInfo.Port[0];
                        UploadGroupPicByTCP(sendQQ, GroupId, uKey, Ip, Port);
                    }
                    SendMessages msg = new SendMessages
                    {
                        SendGroupPicInfo = new SendGroupPicInfos
                        {
                            PicName      = BitConverter.ToString(API.FileHash).Replace("-", "") + ".jpg",
                            PicId1       = 3013326518,
                            PicId2       = 1883293792,
                            picIconWidth = 80,
                            picIconHeigh = 66,
                            picMD5       = "VdcrgQM3T3AaJPtM",
                            picAmount    = 1,
                            picHash      = API.FileHash,
                            picType      = 4,
                            picPix       = 1000,
                            picWidth     = 100,
                            picHeigh     = 104,
                            picSize      = 2500,
                            Field26      = 0,
                            Field29      = 0,
                            Field30      = 0
                        }
                    };
                    MsgList.Add(msg);
                }
            }

            SendGroupMsgStuct SendGroupMessage = new SendGroupMsgStuct
            {
                GroupInformation = new GroupInformations
                {
                    GroupFrom = new GroupFroms {
                        GroupId = GroupId
                    }
                },
                GroupMsgId       = new byte[] { 8, 1, 0x10, 0, 0x18, 0 },
                SendGroupMsgInfo = new SendGroupMsgInfos
                {
                    SendGroupMsg = new SendGroupMsgs {
                        SendMessage = MsgList
                    }
                },
                MsgReqId    = API.QQ.mRequestID,
                MsgRandomId = (new Random()).Next(1, 1879048191) + 268435457,
                Groupcount  = 0
            };

            API.GroupWithdraw.MsgReqId    = API.QQ.mRequestID;
            API.GroupWithdraw.MsgRandomId = SendGroupMessage.MsgRandomId;
            using (var ms = new MemoryStream())
            {
                Serializer.Serialize(ms, SendGroupMessage);
                Debug.Print("发送群消息:" + ms.ToArray().Length.ToString() + "\r\n" + BitConverter.ToString(ms.ToArray()).Replace("-", " "));
                var SendBytes = API.PackCmdHeader("MessageSvc.PbSendMsg", ms.ToArray());
                API.TClient.SendData(API.PackAllHeader(SendBytes));
            }
            return(API.GroupWithdraw);
        }