Exemple #1
0
 /// <summary>
 /// 处理好友状态变化
 /// </summary>
 /// <param name="pollData"></param>
 /// <returns></returns>
 private QQNotifyEvent ProcessBuddyStatusChange(JObject pollData)
 {
     try
     {
         var uin   = pollData["uin"].ToObject <long>();
         var buddy = Context.Store.GetBuddyByUin(uin);
         if (buddy == null)
         {
             buddy = new QQBuddy()
             {
                 Uin = uin
             };
             Context.Store.AddBuddy(buddy);
             var userModule = Context.GetModule <UserModule>(QQModuleType.USER);
             userModule.GetUserInfo(buddy, null);
         }
         var status     = pollData["status"].ToString();
         var clientType = pollData["client_type"].ToObject <int>();
         buddy.Status     = QQStatus.ValueOfRaw(status);
         buddy.ClientType = QQClientTypeInfo.ValueOfRaw(clientType);
         return(new QQNotifyEvent(QQNotifyEventType.BuddyStatusChange, buddy));
     }
     catch (Exception ex)
     {
         return(new QQNotifyEvent(QQNotifyEventType.NetError, ex));
     }
 }
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            var str   = response.ResponseString;
            var json  = JObject.Parse(str);
            var store = Context.Store;

            if (json["retcode"].ToString() == "0")
            {
                var result = json["result"].ToObject <JArray>();
                foreach (var token in result)
                {
                    var obj        = token.ToObject <JObject>();
                    var uin        = obj["uin"].ToObject <long>();
                    var status     = obj["status"].ToString();
                    var clientType = obj["client_type"].ToObject <int>();
                    var buddy      = store.GetBuddyByUinOrAdd(uin);
                    buddy.Status     = QQStatus.ValueOfRaw(status);
                    buddy.ClientType = QQClientTypeInfo.ValueOfRaw(clientType);
                }
                NotifyActionEvent(QQActionEventType.EvtOK, null);
            }
            else
            {
                throw new QQException(QQErrorCode.InvalidResponse, str);
            }
        }
Exemple #3
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            var json    = JObject.Parse(response.GetResponseString());
            var account = Context.Account;

            if (json["retcode"].ToString() == "0")
            {
                var obj = json["result"].ToObject <JObject>();
                try
                {
                    account.Birthday = DateUtils.Parse(obj["birthday"].ToObject <JObject>());
                }
                catch (Exception e)
                {
                    //Context.Logger.LogWarning($"日期转换失败:{obj["birthday"]}", e);
                    account.Birthday = null;
                }

                account.Occupation    = obj["occupation"].ToString();
                account.Phone         = obj["phone"].ToString();
                account.Allow         = (QQAllow)obj["allow"].ToObject <int>();
                account.College       = obj["college"].ToString();
                account.RegTime       = obj["reg_time"]?.ToObject <int>() ?? 0;
                account.Uin           = obj["uin"].ToObject <long>();
                account.Constel       = obj["constel"].ToObject <int>();
                account.Blood         = obj["blood"].ToObject <int>();
                account.Homepage      = obj["homepage"].ToString();
                account.Stat          = obj["stat"]?.ToObject <int>() ?? 0;
                account.Sign          = obj["lnick"].ToString();
                account.VipLevel      = obj["vip_info"].ToObject <int>(); // VIP等级 0为非VIP
                account.Country       = obj["country"].ToString();
                account.City          = obj["city"].ToString();
                account.Personal      = obj["personal"].ToString();
                account.Nickname      = obj["nick"].ToString();
                account.ChineseZodiac = obj["shengxiao"].ToObject <int>();
                account.Email         = obj["email"].ToString();
                account.Province      = obj["province"].ToString();
                account.Gender        = obj["gender"].ToString();
                account.Mobile        = obj["mobile"].ToString();
                account.Vfwebqq       = obj["vfwebqq"].ToString(); // 重要
                var clientType = obj["client_type"];
                if (clientType != null)
                {
                    account.ClientType = QQClientTypeInfo.ValueOfRaw(clientType.ToString());
                }
                NotifyActionEvent(QQActionEventType.EvtOK, account);
            }
            else
            {
                throw new QQException(QQErrorCode.InvalidResponse, response.ResponseString);
            }
        }
Exemple #4
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            var json = JObject.Parse(response.GetResponseString());

            if (json["retcode"].ToString() == "0")
            {
                json = json["result"].ToObject <JObject>();

                // 消除所有成员状态,如果不在线的,webqq是不会返回的。
                foreach (var member in _group.Members)
                {
                    member.Status     = QQStatus.OFFLINE;
                    member.ClientType = QQClientType.Unknown;
                }

                //result/stats
                var stats = json["stats"].ToObject <JArray>();
                for (var i = 0; i < stats.Count; i++)
                {
                    // 下面重新设置最新状态
                    var stat   = stats[i].ToObject <JObject>();
                    var member = _group.GetMemberByUin(stat["uin"].ToObject <long>());
                    if (member != null)
                    {
                        member.ClientType = QQClientTypeInfo.ValueOfRaw(stat["client_type"].ToObject <int>());
                        member.Status     = QQStatus.ValueOfRaw(stat["stat"].ToObject <int>());
                    }
                }

                NotifyActionEvent(QQActionEventType.EvtOK, _group);
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EvtError, QQErrorCode.UnexpectedResponse);
            }
        }
 public override void OnHttpStatusOK(QQHttpResponse response)
 {
     /*
      * {"retcode":0,"result":
      * {"face":0,"birthday":{"month":0,"year":0,"day":0},
      * "phone":"","occupation":"","allow":1,"college":"","uin":2842465527,"blood":0,
      * "constel":0,"homepage":"","stat":10,"country":"","city":"","personal":"","nick":"平凡",
      * "shengxiao":0,"email":"","token":"d04e802bda6ff115e31c3792199f15aa74f92eb435e75d93",
      * "client_type":1,"province":"","gender":"male","mobile":"-"}}
      */
     try
     {
         var json = JObject.Parse(response.GetResponseString());
         if (json["retcode"].ToString() == "0")
         {
             var obj = json["result"].ToObject <JObject>();
             try
             {
                 user.Birthday = DateUtils.Parse(obj["birthday"].ToObject <JObject>());
             }
             catch (FormatException e)
             {
                 /// Context.Logger.LogWarning($"日期转换失败:{obj["birthday"]}", e);
                 user.Birthday = null;
             }
             user.Occupation = obj["occupation"].ToString();
             user.Phone      = obj["phone"].ToString();
             user.Allow      = (QQAllow)obj["allow"].ToObject <int>();
             user.College    = obj["college"].ToString();
             if (obj["reg_time"] != null)
             {
                 user.RegTime = obj["reg_time"].ToObject <int>();
             }
             user.Uin      = obj["uin"].ToObject <long>();
             user.Constel  = obj["constel"].ToObject <int>();
             user.Blood    = obj["blood"].ToObject <int>();
             user.Homepage = obj["homepage"].ToString();
             user.Stat     = obj["stat"].ToObject <int>();
             if (obj["vip_info"] != null)
             {
                 user.VipLevel = obj["vip_info"].ToObject <int>(); // VIP等级 0为非VIP
             }
             user.Country       = obj["country"].ToString();
             user.City          = obj["city"].ToString();
             user.Personal      = obj["personal"].ToString();
             user.Nickname      = obj["nick"].ToString();
             user.ChineseZodiac = obj["shengxiao"].ToObject <int>();
             user.Email         = obj["email"].ToString();
             user.Province      = obj["province"].ToString();
             user.Gender        = obj["gender"].ToString();
             user.Mobile        = obj["mobile"].ToString();
             if (obj["client_type"] != null)
             {
                 user.ClientType = QQClientTypeInfo.ValueOfRaw(obj["client_type"].ToObject <int>());
             }
         }
     }
     catch (Exception e)
     {
         //Context.Logger.LogWarning(e.Message, e);
     }
     NotifyActionEvent(QQActionEventType.EvtOK, user);
 }
Exemple #6
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            /*
             *   {
             *      "retcode": 0,
             *      "result": {
             *          "face": 603,
             *          "birthday": {
             *              "month": 8,
             *              "year": 1895,
             *              "day": 15
             *          },
             *          "occupation": "其他",
             *          "phone": "110",
             *          "allow": 1,
             *          "college": "aaa",
             *          "uin": 1382902354,
             *          "constel": 7,
             *          "blood": 5,
             *          "homepage": "木有",
             *          "stat": 20,
             *          "vip_info": 6,
             *          "country": "乍得",
             *          "city": "",
             *          "personal": "这是简介",
             *          "nick": "ABCD",
             *          "shengxiao": 11,
             *          "email": "*****@*****.**",
             *          "province": "",
             *          "gender": "female",
             *          "mobile": "139********"
             *      }
             *  }
             */
            var json = JObject.Parse(response.GetResponseString());

            if (json["retcode"].ToString() == "0")
            {
                var obj = json["result"].ToObject <JObject>();
                _buddy.Birthday   = DateUtils.Parse(obj["birthday"].ToObject <JObject>());
                _buddy.Occupation = obj["occupation"].ToString();
                _buddy.Phone      = obj["phone"].ToString();
                _buddy.Allow      = (QQAllow)obj["allow"].ToObject <int>();

                _buddy.College = obj["college"].ToString();
                if (obj["reg_time"] != null)
                {
                    _buddy.RegTime = obj["reg_time"].ToObject <int>();
                }
                _buddy.Uin           = obj["uin"].ToObject <long>();
                _buddy.Constel       = obj["constel"].ToObject <int>();
                _buddy.Blood         = obj["blood"].ToObject <int>();
                _buddy.Homepage      = obj["homepage"].ToString();
                _buddy.Stat          = obj["stat"].ToObject <int>();
                _buddy.VipLevel      = obj["vip_info"].ToObject <int>(); // VIP等级 0为非VIP
                _buddy.Country       = obj["country"].ToString();
                _buddy.City          = obj["city"].ToString();
                _buddy.Personal      = obj["personal"].ToString();
                _buddy.Nickname      = obj["nick"].ToString();
                _buddy.ChineseZodiac = obj["shengxiao"].ToObject <int>();
                _buddy.Email         = obj["email"].ToString();
                _buddy.Province      = obj["province"].ToString();
                _buddy.Gender        = obj["gender"].ToString();
                _buddy.Mobile        = obj["mobile"].ToString();
                if (obj["client_type"] != null)
                {
                    _buddy.ClientType = QQClientTypeInfo.ValueOfRaw(obj["client_type"].ToObject <int>());
                }
            }

            NotifyActionEvent(QQActionEventType.EvtOK, _buddy);
        }
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            var json  = JObject.Parse(response.GetResponseString());
            var store = Context.Store;

            if (json["retcode"].ToString() == "0")
            {
                var result = json["result"].ToObject <JObject>();

                //result/info
                var info = result["info"].ToObject <JObject>();
                discuz.Name  = info["discu_name"].ToString();
                discuz.Owner = info["discu_owner"].ToObject <long>();

                //result/mem_list
                var memlist = result["mem_info"].ToObject <JArray>();
                foreach (var t in memlist)
                {
                    var memjson = t.ToObject <JObject>();
                    var member  = discuz.GetMemberByUin(memjson["uin"].ToObject <long>());
                    if (member == null)
                    {
                        member = new QQDiscuzMember();
                        discuz.AddMemeber(member);
                    }
                    member.Uin      = memjson["uin"].ToObject <long>();
                    member.QQ       = memjson["uin"].ToObject <long>(); //这里有用户真实的QQ号
                    member.Nickname = memjson["nick"].ToString();
                    member.Discuz   = discuz;
                }

                // 消除所有成员状态,如果不在线的,webqq是不会返回的。
                discuz.ClearStatus();
                //result/mem_status
                var statlist = result["mem_status"].ToObject <JArray>();
                foreach (var t in statlist)
                {
                    // 下面重新设置最新状态
                    var    statjson = t.ToObject <JObject>();
                    QQUser member   = discuz.GetMemberByUin(statjson["uin"].ToObject <long>());
                    if (statjson["client_type"] != null && member != null)
                    {
                        member.ClientType = QQClientTypeInfo.ValueOfRaw(statjson["client_type"].ToObject <int>());
                        member.Status     = QQStatus.ValueOfRaw(statjson["status"].ToString());
                    }
                }

                //result/mem_info
                var infolist = result["mem_info"].ToObject <JArray>();
                foreach (var t in infolist)
                {
                    var    infojson = t.ToObject <JObject>();
                    QQUser member   = discuz.GetMemberByUin(infojson["uin"].ToObject <long>());
                    member.Nickname = infojson["nick"].ToString();
                }

                NotifyActionEvent(QQActionEventType.EvtOK, store.GetDiscuzList());
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EvtError, new QQException(QQErrorCode.UnexpectedResponse));
            }
        }
Exemple #8
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            var str  = response.GetResponseString();
            var json = JObject.Parse(str);

            if (json["retcode"].ToString() == "0")
            {
                var result = json["result"].ToObject <JObject>();
                var ginfo  = result["ginfo"].ToObject <JObject>();
                _group.Memo  = ginfo["memo"].ToString();
                _group.Level = ginfo["level"].ToObject <int>();
                var ticks = ginfo["createtime"].ToObject <long>() * 1000;
                _group.CreateTime = ticks > DateTime.MaxValue.Ticks ? DateTime.Now : new DateTime(ticks);

                var members = ginfo["members"].ToObject <JArray>();
                for (var i = 0; i < members.Count; i++)
                {
                    var memjson = members[i].ToObject <JObject>();
                    var member  = _group.GetMemberByUin(memjson["muin"].ToObject <long>());
                    if (member == null)
                    {
                        member = new QQGroupMember();
                        _group.Members.Add(member);
                    }
                    member.Uin   = memjson["muin"].ToObject <long>();
                    member.Group = _group;
                    //memjson["mflag"]; //TODO ...
                }

                //result/minfo
                var minfos = result["minfo"].ToObject <JArray>();
                foreach (var token in minfos)
                {
                    var minfo  = token.ToObject <JObject>();
                    var member = _group.GetMemberByUin(minfo["uin"].ToObject <long>());
                    member.Nickname = minfo["nick"].ToString();
                    member.Province = minfo["province"].ToString();
                    member.Country  = minfo["country"].ToString();
                    member.City     = minfo["city"].ToString();
                    member.Gender   = minfo["gender"].ToString();
                }

                //result/stats
                var stats = result["stats"].ToObject <JArray>();
                for (var i = 0; i < stats.Count; i++)
                {
                    // 下面重新设置最新状态
                    var stat   = stats[i].ToObject <JObject>();
                    var member = _group.GetMemberByUin(stat["uin"].ToObject <long>());
                    member.ClientType = QQClientTypeInfo.ValueOfRaw(stat["client_type"].ToObject <int>());
                    member.Status     = QQStatus.ValueOfRaw(stat["stat"].ToObject <int>());
                }

                //results/cards
                if (result["cards"] != null)
                {
                    var cards = result["cards"].ToObject <JArray>();
                    for (var i = 0; i < cards.Count; i++)
                    {
                        var card   = cards[i].ToObject <JObject>();
                        var member = _group.GetMemberByUin(card["muin"].ToObject <long>());
                        if (card["card"] != null && member != null)
                        {
                            member.Card = card["card"].ToString();
                        }
                    }
                }

                //results/vipinfo
                var vipinfos = result["vipinfo"].ToObject <JArray>();
                for (var i = 0; i < vipinfos.Count; i++)
                {
                    var vipinfo = vipinfos[i].ToObject <JObject>();
                    var member  = _group.GetMemberByUin(vipinfo["u"].ToObject <long>());
                    member.VipLevel = vipinfo["vip_level"].ToObject <int>();
                    member.IsVip    = (vipinfo["is_vip"].ToString() != "0");
                }

                NotifyActionEvent(QQActionEventType.EvtOK, _group);
            }
            else
            {
                // NotifyActionEvent(QQActionEventType.EVT_ERROR, QQErrorCode.UNEXPECTED_RESPONSE);
                throw new QQException(QQErrorCode.UnexpectedResponse, str);
            }
        }