public void fetch()
        {
            string jsonstring = sess._get_with_cookies("https://api.vc.bilibili.com/svr_sync/v1/svr_sync/fetch_session_msgs?sender_device_id=1&talker_id=" + talker_id + "&session_type=" + sessiontype + "&size=20&build=0&mobi_app=web");

            lastjson = jsonstring;
            JObject json = (JObject)JsonConvert.DeserializeObject(jsonstring);

            foreach (JObject jb in json["data"]["messages"])
            {
                try
                {
                    PrivMessage p = new PrivMessage(jb, sess);
                    if (!messages.ContainsKey(p))
                    {
                        messages.Add(p, false);
                    }
                }
                catch
                {
                    //一条私信被丢弃
                }
            }

            messages.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);
            loaded = true;
        }
Пример #2
0
        public int CompareTo(object obj)
        {
            if (Equals(obj))
            {
                return(0);
            }

            if (obj == null)
            {
                return(0);
            }
            if ((obj.GetType().Equals(GetType())) == false)
            {
                return(0);
            }
            PrivMessage pv = (PrivMessage)obj;

            if (pv.timestamp.Equals(timestamp))
            {
                return(msg_seqno.CompareTo(pv.msg_seqno));
            }
            else
            {
                return(timestamp.CompareTo(pv.timestamp));
            }
        }
        public void init(JToken json)
        {
            talker_id   = json.Value <int>("talker_id");
            sessiontype = json.Value <int>("session_type");
            session_ts  = json.Value <long>("session_ts");
            unread_cnt  = json.Value <int>("unread_count");
            lastmessage = new PrivMessage(json["last_msg"], sess);
            followed    = json.Value <int>("is_follow") == 1;
            isGroup     = json["group_name"] != null;
            messages    = new Dictionary <PrivMessage, bool>();
            CookieCollection ck = sess.CookieContext;

            uid = int.Parse(ck["DedeUserID"].Value);
        }
Пример #4
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if ((obj.GetType().Equals(GetType())) == false)
            {
                return(false);
            }
            PrivMessage rmt = (PrivMessage)obj;

            return(msg_key.Equals(rmt.msg_key));
        }
        public void updateFromJson(JToken json)
        {
            if (json.Value <int>("unread_count") <= 1)
            {
                PrivMessage p = new PrivMessage(json["last_msg"], sess);
                if (!messages.ContainsKey(p))
                {
                    messages.Add(p, false);
                }

                messages.OrderBy(o => o.Key).ToDictionary(o => o.Key, pp => pp.Value);
            }
            else
            {
                fetch();
            }
        }