Ejemplo n.º 1
0
        public override BaseData onUse(BaseData data)
        {
            Twitter d = data as Twitter;

            if (d.Reply == null)
            {
                d = location302(d);
                d = requestTruncated(d);
                if (!string.IsNullOrEmpty(d.ReplyId) && !string.Equals(d.ReplyId, "null"))
                {
                    string text = mAtEndNameReg.Replace(d.Text, "") + string.Format(" //@{0} ", d.ReplyUser.ScreenName);

                    List <string> urls = new List <string>();
                    urls.AddRange(d.ImgUrls);
                    recursionReply(d, ref text, urls);
                    d.Text    = text.Replace("@" + ((TwitterUser)User).ScreenName, "@" + ((TwitterUser)User).UserName);
                    d.ImgUrls = urls.ToArray();
                }
            }

            return(d);
        }
Ejemplo n.º 2
0
        private void recursionReply(Twitter data, ref string fullText, List <string> fullUrl)
        {
            if (string.IsNullOrEmpty(data.ReplyId))
            {
                return;
            }
            int     times   = 3;
            string  jsonStr = "";
            Twitter reply   = null;

tryRequest:
            try
            {
                times--;
                jsonStr = TwitterApi.getInstance().GetTwitter(data.ReplyId, null, Proxy);
            }
            catch (Exception)
            {
                if (times >= 0)
                {
                    goto tryRequest;
                }
            }
            try
            {
                reply = paserTwitterFormJson(JSON.Parse(jsonStr));
            }
            catch (Exception) { }
            reply = location302(reply);
            reply = requestTruncated(reply);
            try
            {
                fullText += mAtEndNameReg.Replace(mStartAtNameReg.Replace(mStartAtNameReg.Replace(reply.Text, ""), ""), "") + ((string.IsNullOrEmpty(reply.ReplyId) || string.Equals(reply.ReplyId, "null")) ? "" : string.Format(" //@{0} ", reply.ReplyUser.ScreenName));
                fullUrl.AddRange(reply.ImgUrls);
                recursionReply(reply, ref fullText, fullUrl);
                data.Reply = reply;
            }catch (Exception) { }
        }
Ejemplo n.º 3
0
        private void requestReply(Twitter father)
        {
            if (father == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(father.ReplyId) || "null".Equals(father.ReplyId))
            {
                return;
            }
            int     times   = 3;
            string  jsonStr = "";
            Twitter reply   = null;

tryRequest:
            try
            {
                times--;
                jsonStr = TwitterApi.getInstance().GetTwitter(father.ReplyId, null, Proxy);
            }
            catch (Exception)
            {
                if (times >= 0)
                {
                    goto tryRequest;
                }
            }
            try
            {
                reply = paserTwitterFormJson(JSON.Parse(jsonStr));
            }
            catch (Exception) { }
            reply        = location302(reply);
            reply        = requestTruncated(reply);
            reply.Text   = mAtEndNameReg.Replace(mStartAtNameReg.Replace(mStartAtNameReg.Replace(reply.Text, ""), ""), "");
            father.Reply = reply;
        }
Ejemplo n.º 4
0
        public override BaseData onUse(BaseData data)
        {
            Twitter d = data as Twitter;

            if (d.EverUsed)
            {
                return(d);
            }
            d.EverUsed = true;

            /*
             * for(int i = 0;i < d.ExpandedUrls.Length; i++)
             * {
             *  d.Text += " " + d.ExpandedUrls[i];
             * }
             */
            d = location302(d);
            d = requestTruncated(d);
            requestReply(d);
            recursionTwitter(d);
            d.Text = mHttpTwitterReg2.Replace(mHttpTwitterReg.Replace(d.Text, ""), "");
            return(d);
        }
Ejemplo n.º 5
0
        private Twitter location302(Twitter d)
        {
            MatchCollection matches = mHttpUriReg.Matches(d.Text);

            foreach (Match match in matches)
            {
                string location = null;
reTry:
                try
                {
                    location = request.Location(match.Value, Proxy, null);
                }
                catch (TimeoutException)
                {
                    goto reTry;
                }
                if (!string.IsNullOrEmpty(location))
                {
                    d.Text = d.Text.Replace(match.Value, location);
                }
            }
            return(d);
        }
Ejemplo n.º 6
0
        public override BaseData onUse(BaseData data)
        {
            Twitter d = data as Twitter;

            if (d.Reply == null)
            {
                int times = 3;
                if (bool.Parse(d.Truncated))
                {
                    Twitter newData = null;
tryRequest:
                    try
                    {
                        times--;
                        string   tr       = TwitterApi.getInstance().GetTwitter(d.Id, null, Proxy);
                        JSONNode jsonNode = JSON.Parse(tr);
                        newData = paserTwitterFormJson(jsonNode);
                    }
                    catch (Exception)
                    {
                        if (times >= 0)
                        {
                            goto tryRequest;
                        }
                    }
                    if (newData != null)
                    {
                        d = newData;
                    }
                }
                if (!string.IsNullOrEmpty(d.ReplyId) && !string.Equals(d.ReplyId, "null"))
                {
                    string text = mAtEndNameReg.Replace(d.Text, "") + string.Format(" //@{0} ", d.ReplyUser.ScreenName);

                    List <string> urls = new List <string>();
                    urls.AddRange(d.ImgUrls);
                    recursionReply(d, ref text, urls);
                    d.Text    = text.Replace(((TwitterUser)User).ScreenName, ((TwitterUser)User).UserName);
                    d.ImgUrls = urls.ToArray();
                }
                MatchCollection matches = mHttpUriReg.Matches(d.Text);
                foreach (Match match in matches)
                {
                    string location = null;
reTry:
                    try
                    {
                        location = request.Location(match.Value, Proxy, null);
                    }
                    catch (TimeoutException)
                    {
                        goto reTry;
                    }
                    if (!string.IsNullOrEmpty(location))
                    {
                        d.Text = d.Text.Replace(match.Value, location);
                    }
                }
            }

            return(d);
        }