Exemplo n.º 1
0
 /// <summary>
 /// 处理好友状态变化
 /// </summary>
 /// <param name="pollData"></param>
 /// <returns></returns>
 public 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);
             UserModule 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 = QQClientType.ValueOfRaw(clientType);
         return(new QQNotifyEvent(QQNotifyEventType.BUDDY_STATUS_CHANGE, buddy));
     }
     catch (Exception ex)
     {
         return(new QQNotifyEvent(QQNotifyEventType.NET_ERROR, ex));
     }
 }
Exemplo n.º 2
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            JObject json = JObject.Parse(response.GetResponseString());

            if (json["retcode"].ToString() == "0")
            {
                JObject obj = json["result"].ToObject <JObject>();
                try
                {
                    buddy.Birthday = DateUtils.Parse(obj["birthday"].ToObject <JObject>());
                }
                catch (FormatException e)
                {
                    MyLogger.Default.Warn($"日期转换失败:{obj["birthday"]}", e);
                    buddy.Birthday = default(DateTime);
                }
                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 = QQClientType.ValueOfRaw(obj["client_type"].ToObject <int>());
                }
            }

            NotifyActionEvent(QQActionEventType.EVT_OK, buddy);
        }
Exemplo n.º 3
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            JObject json  = JObject.Parse(response.GetResponseString());
            QQStore store = Context.Store;

            if (json["retcode"].ToString() == "0")
            {
                JArray result = json["result"].ToObject <JArray>();
                for (int i = 0; i < result.Count; i++)
                {
                    JObject obj        = result[i].ToObject <JObject>();
                    long    uin        = obj["uin"].ToObject <long>();
                    string  status     = obj["status"].ToString();
                    int     clientType = obj["client_type"].ToObject <int>();

                    QQBuddy buddy = store.GetBuddyByUin(uin);
                    buddy.Status     = QQStatus.ValueOfRaw(status);
                    buddy.ClientType = QQClientType.ValueOfRaw(clientType);
                }
            }

            NotifyActionEvent(QQActionEventType.EVT_OK, store.GetOnlineBuddyList());
        }
Exemplo n.º 4
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            JObject json = JObject.Parse(response.GetResponseString());

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

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

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

                NotifyActionEvent(QQActionEventType.EVT_OK, group);
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EVT_ERROR, QQErrorCode.UNEXPECTED_RESPONSE);
            }
        }
Exemplo n.º 5
0
 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
     {
         JObject json = JObject.Parse(response.GetResponseString());
         if (json["retcode"].ToString() == "0")
         {
             JObject obj = json["result"].ToObject <JObject>();
             try
             {
                 user.Birthday = DateUtils.Parse(obj["birthday"].ToObject <JObject>());
             }
             catch (FormatException e)
             {
                 MyLogger.Default.Warn($"日期转换失败:{obj["birthday"]}", e);
                 user.Birthday = default(DateTime);
             }
             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 = QQClientType.ValueOfRaw(obj["client_type"].ToObject <int>());
             }
         }
     }
     catch (Exception e)
     {
         MyLogger.Default.Warn(e.Message, e);
     }
     NotifyActionEvent(QQActionEventType.EVT_OK, user);
 }
Exemplo n.º 6
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            JObject json = JObject.Parse(response.GetResponseString());

            if (json["retcode"].ToString() == "0")
            {
                json = json["result"].ToObject <JObject>();
                JObject ginfo = json["ginfo"].ToObject <JObject>();
                group.Memo       = ginfo["memo"].ToString();
                group.Level      = ginfo["level"].ToObject <int>();
                group.CreateTime = new DateTime(ginfo["createtime"].ToObject <int>());

                JArray members = ginfo["members"].ToObject <JArray>();
                for (int i = 0; i < members.Count; i++)
                {
                    JObject       memjson = members[i].ToObject <JObject>();
                    QQGroupMember 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
                JArray minfos = json["minfo"].ToObject <JArray>();
                for (int i = 0; i < minfos.Count; i++)
                {
                    JObject       minfo  = minfos[i].ToObject <JObject>();
                    QQGroupMember member = group.GetMemberByUin(minfo["uin"].ToObject <int>());
                    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
                JArray stats = json["stats"].ToObject <JArray>();
                for (int i = 0; i < stats.Count; i++)
                {
                    // 下面重新设置最新状态
                    JObject       stat   = stats[i].ToObject <JObject>();
                    QQGroupMember member = group.GetMemberByUin(stat["uin"].ToObject <long>());
                    member.ClientType = QQClientType.ValueOfRaw(stat["client_type"].ToObject <int>());
                    member.Status     = QQStatus.ValueOfRaw(stat["stat"].ToObject <int>());
                }

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

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

                NotifyActionEvent(QQActionEventType.EVT_OK, group);
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EVT_ERROR, QQErrorCode.UNEXPECTED_RESPONSE);
            }
        }
Exemplo n.º 7
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            JObject json  = JObject.Parse(response.GetResponseString());
            QQStore store = Context.Store;

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

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

                //result/mem_list
                JArray memlist = result["mem_info"].ToObject <JArray>();
                foreach (JToken t in memlist)
                {
                    JObject        memjson = t.ToObject <JObject>();
                    QQDiscuzMember 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
                JArray statlist = result["mem_status"].ToObject <JArray>();
                foreach (JToken t in statlist)
                {
                    // 下面重新设置最新状态
                    JObject statjson = t.ToObject <JObject>();
                    QQUser  member   = discuz.GetMemberByUin(statjson["uin"].ToObject <long>());
                    if (statjson["client_type"] != null && member != null)
                    {
                        member.ClientType = QQClientType.ValueOfRaw(statjson["client_type"].ToObject <int>());
                        member.Status     = QQStatus.ValueOfRaw(statjson["status"].ToString());
                    }
                }

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

                NotifyActionEvent(QQActionEventType.EVT_OK, store.GetDiscuzList());
            }
            else
            {
                NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE));
            }
        }