Exemplo n.º 1
0
        public void updateSessions()
        {
            sess._get_with_cookies("https://api.vc.bilibili.com/session_svr/v1/session_svr/new_sessions?begin_ts=" + last_refresh + "&build=0&mobi_app=web");
            string rtv = sess._get_with_cookies("https://api.vc.bilibili.com/session_svr/v1/session_svr/ack_sessions?begin_ts=" + last_refresh + "&build=0&mobi_app=web");

            lastjson = rtv;
            JObject raw_json = (JObject)JsonConvert.DeserializeObject(rtv);

            if (raw_json.Value <int>("code") != 0)
            {//发生错误
                throw new ApiRemoteException(raw_json);
            }
            List <PrivMessageSession> sessionlist = new List <PrivMessageSession>();

            foreach (JToken jobj in raw_json["data"]["session_list"])
            {
                PrivMessageSession session = new PrivMessageSession(jobj, sess);
                if (session.followed)
                {
                    if (!followed_sessions.Contains(session))
                    {
                        followed_sessions.Add(session);
                    }
                    else
                    {
                        followed_sessions[followed_sessions.IndexOf(session)].updateFromJson(jobj);
                    }
                }
                else if (!session.isGroup)
                {
                    if (!unfollowed_sessions.Contains(session))
                    {
                        unfollowed_sessions.Add(session);
                    }
                    else
                    {
                        unfollowed_sessions[unfollowed_sessions.IndexOf(session)].updateFromJson(jobj);
                    }
                }
                else
                {
                    if (!group_sessions.Contains(session))
                    {
                        group_sessions.Add(session);
                    }
                    else
                    {
                        group_sessions[group_sessions.IndexOf(session)].updateFromJson(jobj);
                    }
                }
            }
            last_refresh = TimestampHandler.GetTimeStamp16(DateTime.Now);
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if ((obj.GetType().Equals(GetType())) == false)
            {
                return(false);
            }
            PrivMessageSession rmt = (PrivMessageSession)obj;

            return(talker_id.Equals(rmt.talker_id));
        }
Exemplo n.º 3
0
        public void fetchGroups()
        {
            string rtv = sess._get_with_cookies("https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions?session_type=3&group_fold=1&unfollow_fold=1&sort_rule=2&build=0&mobi_app=web");

            lastjson = rtv;
            JObject raw_json = (JObject)JsonConvert.DeserializeObject(rtv);

            if (raw_json.Value <int>("code") != 0)
            {//发生错误
                throw new ApiRemoteException(raw_json);
            }
            List <PrivMessageSession> sessionlist = new List <PrivMessageSession>();

            foreach (JToken jobj in raw_json["data"]["session_list"])
            {
                PrivMessageSession session = new PrivMessageSession(jobj, sess);
                if (!group_sessions.Contains(session))
                {
                    group_sessions.Add(session);
                }
            }
        }