예제 #1
0
        public static Tweet TweetMapper(TwitterStatus originalTweet)
        {
            if(originalTweet == null)
                return new Tweet();

            var tweet = new Tweet();
            TwitterStatus twitterStatus;
            if (originalTweet.RetweetedStatus != null)
            {
                tweet.OriginalId = originalTweet.Id;
                tweet.IsRetweeted = true;
                tweet.RetweetedBy = originalTweet.User.Name;
                twitterStatus = originalTweet.RetweetedStatus;
            }
            else
            {
                twitterStatus = originalTweet;
                tweet.OriginalId = twitterStatus.Id;
            }

            tweet.Id = twitterStatus.Id;
            tweet.ImageUrl = twitterStatus.User.ProfileImageUrl;
            tweet.Text = FormatHelper.HtmlToBbCodeText(twitterStatus.TextAsHtml);
            tweet.UserFullName = twitterStatus.User.Name;
            tweet.Created = FormatHelper.UniDate(twitterStatus.CreatedDate);
            tweet.IsNew = true;
            tweet.IsFavorited = twitterStatus.IsFavorited;
            tweet.IsExpanded = true;

            return tweet;
        }
예제 #2
0
 public Description(MainWindow wi, TwitterStatus st)
 {
     isrepd = false;
     w = wi;
     os = st;
     InitializeComponent();
 }
예제 #3
0
	//--------------------------------------
	// INITIALIZE
	//--------------------------------------

	public TwitterUserInfo(string data) {
		_rawJSON = data;


		IDictionary JSON =  ANMiniJSON.Json.Deserialize(_rawJSON) as IDictionary;	


		_id 								= System.Convert.ToString(JSON["id"]);
		_name 								= System.Convert.ToString(JSON["name"]);
		_description 						= System.Convert.ToString(JSON["description"]);
		_screen_name 						= System.Convert.ToString(JSON["screen_name"]);


		_lang 								= System.Convert.ToString(JSON["lang"]);
		_location 							= System.Convert.ToString(JSON["location"]);


		_profile_image_url 					= System.Convert.ToString(JSON["profile_image_url"]);
		_profile_image_url_https 			= System.Convert.ToString(JSON["profile_image_url_https"]);
		_profile_background_image_url 		= System.Convert.ToString(JSON["profile_background_image_url"]);
		_profile_background_image_url_https = System.Convert.ToString(JSON["profile_background_image_url_https"]);


		_friends_count  					= System.Convert.ToInt32(JSON["friends_count"]);
		_statuses_count 					= System.Convert.ToInt32(JSON["statuses_count"]);

		_profile_text_color 	 			= HexToColor(System.Convert.ToString(JSON["profile_text_color"]));
		_profile_background_color 			= HexToColor(System.Convert.ToString(JSON["profile_background_color"]));


		_status =  new TwitterStatus(JSON["status"] as IDictionary);
	}
예제 #4
0
        public UIElement CreateFavoritePanel(TwitterStatus st, TwitterUser us)
        {
            StackPanel sp = new StackPanel();
            StackPanel abp = new StackPanel();
            abp.Orientation = Orientation.Horizontal;
            var ab = new TextBlock();

            ab.Text = String.Format(MessageMentionFavoritedFormat, us.Name);
            ab.FontSize = 18;
            var abim = new Image();
            abim.Width = 36;
            abim.Height = 36;
            abim.MouseDown += im_MouseDown2;
            abim.Tag = sp;//TODO : ここ
            abim.Source = new BitmapImage(new Uri(us.ProfileImageUrlHttps));//TODO : ここ
            abp.Children.Add(abim);
            abp.Children.Add(ab);

            var te = new TextBlock();
            te.FontSize = 13;
            te.Foreground = Brushes.LightGray;
            te.Text = st.TextDecoded;

            sp.Children.Add(abp);
            sp.Children.Add(te);
            sp.Tag = us;

            return sp;
        }
예제 #5
0
 public Description(MainWindow wi, long id)
 {
     isrepd = true;
     w = wi;
     os = w.Service.GetTweet(new GetTweetOptions { Id = id, IncludeEntities = true });
     InitializeComponent();
 }
예제 #6
0
        public bool Parse(TwitterStatus tweet)
        {
            var text = tweet.Text;
            var date = tweet.CreatedDate;

            var option = RegexOptions.IgnoreCase | RegexOptions.Singleline;
            Regex r = new Regex(@"PeerCastで配信中!(.*?)\s?\[([^\]]*)\s-\s([^\]]*)\]「(.*)」?\shttps?://t.co/", option);
            MatchCollection mc = r.Matches(text);
            if (mc.Count == 0)
            {
                return false;
            }
            foreach (Match m in mc)
            {
                name = m.Groups[1].ToString();
                genre = m.Groups[2].ToString();
                desc = m.Groups[3].ToString();
                comment = m.Groups[4].ToString();
                encodech = Uri.EscapeDataString(name);
                //Console.WriteLine("{0} {1} {2} {3}", ch, genre, desc, comment);
                break;
            }

            TimeSpan ts = DateTime.Now - date;
            time = ts.ToString(@"hh\:mm");
            expandedurl = GetExpandUrl(tweet);

            return true;
        }
 public TwitterFactory SendMessage(string message)
 {
     var options = new SendTweetOptions();
     options.Status = ScoresMessage + message;
     
     Status = Service.SendTweet(options);
     return this;
 }
 public TwitterWallMessage(TwitterStatus tweet)
 {
     TweetID = tweet.Id;
     Name = tweet.User.Name;
     Username = tweet.User.ScreenName;
     ProfileImage = tweet.User.ProfileImageUrl;
     Text = tweet.Text;
     Created_at = tweet.CreatedDate;
 }
예제 #9
0
 private DisplayItem ConvertToDataItem(TwitterStatus status)
 {
     return new DisplayItem
     {
         MediaPlatform = SocialMediaName,
         Data = status.TextAsHtml,
         Username = status.User.ScreenName,
         Url = status.User.Url
     };
 }
예제 #10
0
 public NGTweeterStatus Convert(TwitterStatus twitterStatus)
 {
     return new NGTweeterStatus
         {
             Id = twitterStatus.Id,
             User = new TweeterUserAdapter().Convert(twitterStatus.User),
             Tweet = twitterStatus.Text,
             CreatedDate = twitterStatus.CreatedDate.AddHours(8),
             RetweetedStatus = twitterStatus.RetweetedStatus != null ? Convert(twitterStatus.RetweetedStatus) : null
         };
 }
예제 #11
0
 public static Tweet CreateTweetFromTwitterStatus(TwitterStatus status)
 {
     return new Tweet
                {
                    Id = status.Id.ToString(CultureInfo.InvariantCulture),
                    Status = status.Text,
                    User = CreateUserFromTwitterUser(status.User),
                    CreatedDate = status.CreatedDate,
                    Links = status.TextLinks.ToList()
                };
 }
예제 #12
0
 public TegakiDrawWindow(MainWindow mw, DateTime d, TwitterStatus st)
     : this(mw, d)
 {
     IsReply.IsChecked = true;
     TweetDesc.Text += "@" + st.User.ScreenName + " ";
     ReplyID.Text = st.Id.ToString();
     foreach (var m in st.Entities.Mentions)
     {
         TweetDesc.Text += "@" + m.ScreenName + " ";
     }
 }
예제 #13
0
 public static Tweet NewTweet(TwitterStatus Status)
 {
     return new TweetClass {
     Id = Status.Id,
     Content = Status.Text,
     Author = NewUser(Status.User),
     Picture = Status.User.ProfileImageUrl,
     Date = Status.CreatedDate.ToString(),
     Source = Status.Source,
     ReplyTo = Status.InReplyToStatusId
     };
 }
예제 #14
0
 private void ReceiveResponse(TwitterStatus status, TwitterResponse response)
 {
     if (status != null && response.StatusCode == HttpStatusCode.OK)
     {
         if (Completed != null)
             Completed(this, new EventArgs());
     }
     else
     {
         if (Error != null)
             Error(this, response);
     }
 }
예제 #15
0
 public static TwitterStatus SearchToStatus(TwitterSearchStatus search)
 {
     TwitterStatus status = new TwitterStatus
     {
         User = search.Author as TwitterUser,
         Text = search.Text,
         TextAsHtml = search.TextAsHtml,
         Source = search.Source,
         Id = search.Id,
         CreatedDate = search.CreatedDate,
         Entities = search.Entities
     };
     return status;
 }
예제 #16
0
파일: Twitter.cs 프로젝트: raouldc/OptiDev
        /// <summary>
        ///     Utility method that gets the image urls for a tweet.
        /// </summary>
        /// <param name="tweet"></param>
        /// <returns> A list of strings containing media urlss</returns>
        public List<String> getImageUrlsForTweet(TwitterStatus tweet)
        {
            List<String> urls = new List<String>();
            var media = tweet.Entities.Media;
            foreach (var m in media)
            {
                if (m.MediaType == TwitterMediaType.Photo)
                {
                    urls.Add(m.MediaUrl);
                }
            }

            return urls;
        }
        static void Main(string[] args)
        {
            string _consumerKey = "JXTOavtgUIN3ucDNRX3qsG5HM",
                _consumerSecret = "zf7szYPlnz4RG4utTsHnQRrreye4aNDoj8SNw6yiuklG9roDaj",
                _accessToken = "65598981-Hbx6HVVi1prAkW1MkzhBEw8oX2vNTti1UMK4BAAiS",
                _accessTokenSecret = "yuQWecLhU5GqBUgdhysiJm7hbBGLCnmTNEInZvu5xOiiF";
            var service1 = new TwitterService(_consumerKey, _consumerSecret);
            service1.AuthenticateWith(_accessToken, _accessTokenSecret);

            var block = new AutoResetEvent(false);
            TwitterStatus[] searchResult = new TwitterStatus[0];

            service1.Search(new SearchOptions() { Q = ":)", Count = 20, IncludeEntities = true, Lang = "en" }, (result, respone) =>
            {
                Console.WriteLine("On going...");
                HttpStatusCode code = respone.StatusCode;

                if (code == HttpStatusCode.OK)
                {
                    searchResult = new TwitterStatus[result.Statuses.Count()];
                    result.Statuses.ToList().CopyTo(searchResult);
                    block.Set();
                }
            });

            //TwitterRateLimitStatus rate = service1.Response.RateLimitStatus;
            //Console.WriteLine("You have used " + rate.RemainingHits + " out of your " + rate.HourlyLimit);

            Console.WriteLine("Out going...");
            block.WaitOne();
            service1.CancelStreaming();
            if (searchResult.Count() > 0)
            {
                WebClient webClient = new WebClient();
                StreamWriter writer = new StreamWriter("out.txt");
                for (int i = 0; i < searchResult.Count(); i++){
                    var photo = searchResult[i].Entities.Media.FirstOrDefault(m => m.MediaType == TwitterMediaType.Photo);
                    string attachedPhoto = "-";
                    if (photo != null)
                    {
                        attachedPhoto = "O";
                        webClient.DownloadFile(photo.MediaUrl, searchResult[i].Id + ".jpg");
                    }
                    string s = searchResult[i].Id + "\t" + attachedPhoto + "\t" + searchResult[i].User.ScreenName + "\t" + searchResult[i].Text;
                    writer.WriteLine(s);
                }
                writer.Close();
            }
            Console.WriteLine("Finish");
        }
예제 #18
0
 public static Tweet CreateTweetFromTwitterStatus(TwitterStatus status)
 {
     return new Tweet
                {
                    Id = status.Id.ToString(CultureInfo.InvariantCulture),
                    Status = status.Text,
                    User = CreateUserFromTwitterUser(status.User),
                    CreatedDate = status.CreatedDate,
                    Links = status.Entities.Urls.Select(x => new Uri(x.Value)).ToList(),
                    Mentions = status.Entities.Mentions.Select(x => x.ScreenName).ToList(),
                    InReplyToStatusId = GetInReplyToStatusId(status),
                    IsArchived = false,
                    IsRead = false
                };
 }
        public void TweetMapper_ReTweet_Valid()
        {
            var date = DateTime.Now;
            var twitterStatus = new TwitterStatus
                {
                    Id = 23,
                    User = new TwitterUser
                        {
                            ProfileImageUrl = "http://mycustom.image.com/myface.jpg",
                            Name = "My Name"
                        },
                    RetweetedStatus = new TwitterStatus
                        {
                            Id = 45,
                            User = new TwitterUser
                            {
                                ProfileImageUrl = "http://mycustom.image.com/myfancyface.jpg",
                                Name = "My Fancy Name"
                            },
                            TextAsHtml = "Awesome! RT <a href=\"https://twitter.com/jhalbrecht\" target=\"_blank\">@jhalbrecht</a> Ah-Ha moments coming Fast and Furious <a href=\"https://twitter.com/ShawnWildermuth\" target=\"_blank\">@ShawnWildermuth</a>'s \"Building a Site with Bootstrap, AngularJS, ASP[.]NET...\"",
                            CreatedDate = date.AddDays(-2),
                            IsFavorited = false
                        },
                    TextAsHtml = "Watching some fish jump @ Issaquah Salmon Days <a href=\"http://instagram.com/p/fJGGVDCndT/\" target=\"_blank\">http://t.co/rPhK2JPvBP</a>",
                    CreatedDate = date,
                    IsFavorited = true
                };

            var expected = new Tweet
                {
                    Id = twitterStatus.RetweetedStatus.Id,
                    Created = FormatHelper.UniDate(twitterStatus.RetweetedStatus.CreatedDate),
                    ImageUrl = twitterStatus.RetweetedStatus.User.ProfileImageUrl,
                    IsExpanded = true,
                    IsFavorited = twitterStatus.RetweetedStatus.IsFavorited,
                    IsNew = true,
                    IsRetweeted = true,
                    OriginalId = twitterStatus.Id,
                    RetweetedBy = twitterStatus.User.Name,
                    Text = FormatHelper.HtmlToBbCodeText(twitterStatus.RetweetedStatus.TextAsHtml),
                    UserFullName = twitterStatus.RetweetedStatus.User.Name
                };

            var tweetMapper = TweetTransformer.TweetMapper(twitterStatus);

            tweetMapper.ShouldBeEquivalentTo(expected);
        }
예제 #20
0
        /// <summary>
        /// 情報を表示
        /// </summary>
        /// <param name="s">ステタス</param>
        void SetInfo(TwitterStatus s)
        {
            os = s;
            if (s.RetweetedStatus == null)
            {
                SetWith(s, JObject.Parse(s.RawSource));
            }
            else
            {
                SetWith(s.RetweetedStatus, JObject.Parse(s.RawSource)["retweeted_status"]);
            }

            if (s.InReplyToStatusId != null)
            {
                ButtonShowReply.Dispatch(() => ButtonShowReply.IsEnabled = true);
            }
        }
        private static string getTweetKey(TwitterStatus tweet)
        {
            string tempstr = tweet.RawSource.Substring(tweet.RawSource.LastIndexOf("screen_name"));
            int tempindex = tweet.RawSource.LastIndexOf("screen_name") + 15;
            int tempindex2 = tempstr.IndexOf(",") - 16;

            return /*"tweet.User: "******"<br>" +
                   "tweet.RetweetedStatus: " + tweet.RetweetedStatus + "<br>" +
                   "tweet.Location: " + tweet.Location + "<br>" +
                   "tweet.Id: " + tweet.Id + "<br>" +
                   "tweet.Entities: " + tweet.Entities + "<br>" +
                   "tweet.Author: " + tweet.Author + "<br>" +
                   "tweet.RawSource: " + tweet.RawSource + "<br>" +*/
                //tweet.RawSource.Contains("screen_name") + "<br>" +  //tweet.RawSource.Substring(tweet.RawSource.LastIndexOf("screen_name:")) + "<br>" +
                   tweet.RawSource.Substring(tempindex, tempindex2) +
                   ": " + "[" + tweet.CreatedDate + "] : " + tweet.Text;
            //return tweet.User + " " + "[" + tweet.CreatedDate + "] : " + tweet.Text;
        }
예제 #22
0
        public TweetPage(KbtterContext ct, TwitterStatus st)
        {
            InitializeComponent();
            ctx = ct;
            stat = st;
            dynraw = JObject.Parse(st.RawSource);
            if (stat.RetweetedStatus != null)
            {
                rtuser = stat.User;

                stat = stat.RetweetedStatus;
                dynraw = dynraw.retweeted_status;
                this.Background = new SolidColorBrush(new Color { R = 200, G = 255, B = 200, A = 127 });
            }
            else
            {
                this.Background = new SolidColorBrush(new Color { R = 200, G = 255, B = 255, A = 127 });
            }
            SetStatus();
        }
예제 #23
0
        public static ListViewItem GetRecordByStatus(TwitterStatus status, ref TwitterModelClass tmc)
        {
            ListViewItem item = new ListViewItem();
            item.Text = status.Id.ToString();
            item.Name = item.Text;
            item.SubItems.Add(status.User.ScreenName);
            item.SubItems.Add(WebUtility.HtmlDecode(GetTextWithReplacingURL(status)));
            item.Tag = status;
            if (isMentionToMe(status, ref tmc))
                item.ImageIndex = 0;
            else if (status.User.Id == tmc.MyID)
                item.ImageIndex = 1;
            else if (status.RetweetedStatus != null)
                item.ImageIndex = 2;

            if (!tmc.FollowerID.Contains(status.User.Id))
                item.ForeColor = Color.Blue;

            return item;
        }
예제 #24
0
 public QuestionViewModel(TwitterStatus twitterStatus)
 {
     Channel = MessageChannel.Twitter;
     To = "";
     From = twitterStatus.User != null ? twitterStatus.User.Name : "LS#er";
     Content = twitterStatus.Text;
     Msg_Id = twitterStatus.Id;
     DateAsked = twitterStatus.CreatedDate.ToShortDateString();
     Keyword = "";
     if (!string.IsNullOrEmpty(Content))
     {
         var aimlPath = HttpContext.Current.Server.MapPath("~/aiml/");
         var chatbot = new DoctorSharp(aimlPath);
         var answer = chatbot.Ask(From, Content);
         Answer = answer;
     }
     else
     {
         Answer = "There was no question.";
     }
 }
예제 #25
0
        public TweetReply(TwitterStatus status)
        {
            Point screenPoint = Cursor.Position;
            Rectangle sb = Screen.PrimaryScreen.Bounds;

            if (screenPoint.X + Width > sb.Right)
            {
                screenPoint.X = sb.Right - Width;
            }

            if (screenPoint.Y + Height > sb.Bottom)
            {
                screenPoint.Y = sb.Bottom - Height;
            }

            InitializeComponent();
            Location = screenPoint;

            tweetdisplay1.setdata(status);
            writeTweet1.setText("@"+status.User.ScreenName+" ");
        }
예제 #26
0
        public void Execute(Bot bot)
        {
            var now = DateTime.Now;

            Debug.WriteLine(string.Format("Fetching from tha twatters! - {0:HH.mm.ss} < {1:HH.mm.ss}", lastRun, now));

            lastRun = now;

            var twitterService = new TwitterService(ConsumerKey, ConsumerSecret);

            twitterService.AuthenticateWith(Token, TokenSecret);

            List<TwitterStatus> latestTweets;

            if (latestTweet == null)
            {
                latestTweets = twitterService.ListTweetsOnSpecifiedUserTimeline(TwitterUserName, tweetLimit).ToList();
            }
            else
            {
                latestTweets = twitterService.ListTweetsOnSpecifiedUserTimelineSince(TwitterUserName, latestTweet.Id, tweetLimit).ToList();
            }

            if (!latestTweets.Any())
            {
                return;
            }

            latestTweet = latestTweets.First();

            foreach (var room in bot.Rooms)
            {
                bot.Say(string.Format("Latests tweets from @{0}", TwitterUserName), room);

                foreach (var tweet in latestTweets)
                {
                    bot.Say(tweet.TextDecoded, room);
                }
            }
        }
예제 #27
0
 public void Favorited(TwitterUser source, TwitterStatus target)
 {
 }
예제 #28
0
 public void MessageReceived(TwitterStatus status)
 {
 }
예제 #29
0
 public void OnStatus(TwitterStatus status)
 {
     _statusHandler(status);
 }
예제 #30
0
        public void TestTokenValidation()
        {
            OAuthTokens fakeTokens = new OAuthTokens();

            TwitterStatus.Update(fakeTokens, "This shouldn't work");
        }
        void NewTweet(TwitterStatus twitterizerStatus)
        {
            Tweet tweet = this._translationService.ConvertToViewModel(twitterizerStatus);

            this._repository.Add(tweet);
        }
예제 #32
0
 public void RetweetRetweeted(TwitterUser source, TwitterUser target, TwitterStatus status)
 {
 }
예제 #33
0
 public static IEnumerable <Inline> FlowContentInlines(TwitterStatus twitterStatus, ISettings settings)
 {
     twitterStatus.FlowContent ??= FlowContentNodes(twitterStatus).ToArray();
     var nodes = ((FlowContentNodeType, string)[])twitterStatus.FlowContent;
예제 #34
0
 public NotificationData(SlimNotificationKind kind, TwitterUser source, TwitterStatus targetStatus)
 {
     this.Kind         = kind;
     this.SourceUser   = source;
     this.TargetStatus = targetStatus;
 }
예제 #35
0
 protected abstract bool CheckAcceptStatusCore(TwitterStatus status);
예제 #36
0
 protected override bool CheckAcceptStatusCore(TwitterStatus status)
 {
     // only from web-fetching
     return(true);
 }
예제 #37
0
 public void Retweeted(TwitterUser source, TwitterStatus original, TwitterStatus retweet)
 {
 }
예제 #38
0
 public void Tweet(TwitterService twitterService, string msg, long tweetID)
 {
     TwitterStatus result = twitterService.SendTweet(new SendTweetOptions {
         Status = msg, InReplyToStatusId = tweetID
     });
 }
예제 #39
0
 public void OnStatus(TwitterStatus status)
 {
     StatusInbox.Enqueue(status);
 }
예제 #40
0
 public void Retweeted(TwitterUser source, TwitterStatus target)
 {
 }
예제 #41
0
 public void Quoted(TwitterUser source, TwitterStatus original, TwitterStatus quote)
 {
 }
예제 #42
0
 void AddStatusToTimeline(TwitterStatus st)
 {
     var te = GetTemplate("SelectBorderListBoxItem");
     var el = new ListBoxItem { Content = new Frame { Content = new TweetPage(context, st) }, Template = te };
     if (context.TimelineReverse)
     {
         ListBoxTimeline.Items.Add(el);
         if (ListBoxTimeline.Items.Count > context.TimelineMaxStatusCount)
         {
             ListBoxTimeline.Items.RemoveAt(0);
         }
     }
     else
     {
         ListBoxTimeline.Items.Insert(0, el);
         if (ListBoxTimeline.Items.Count > context.TimelineMaxStatusCount)
         {
             ListBoxTimeline.Items.RemoveAt(context.TimelineMaxStatusCount);
         }
     }
 }
예제 #43
0
 protected override bool CheckAcceptStatusCore(TwitterStatus status)
 {
     return(_filterFunc(status));
 }
 private void SendTweetInfo(IrcClient client, IList<IIrcMessageTarget> targets, TwitterStatus tweet)
 {
     client.LocalUser.SendMessage(targets, "@{0}: {1}", tweet.User.ScreenName, tweet.Text);
 }
예제 #45
0
 public UnfavoritedEvent(TwitterUser user, TwitterStatus target)
     : base(user, target)
 {
 }
예제 #46
0
 public void StatusReceived(TwitterStatus status)
 {
 }
예제 #47
0
 public TweetDisplay(TwitterStatus _twitterStatus, string _eventContent, string _year)
 {
     twitterStatus = _twitterStatus;
     eventContent  = _eventContent;
     year          = _year;
 }
예제 #48
0
 public void MentionReceived(TwitterStatus status)
 {
 }
예제 #49
0
 private bool CheckAcceptStatus(TwitterStatus status)
 {
     return(!MuteBlockManager.IsUnwanted(status) && CheckAcceptStatusCore(status));
 }
예제 #50
0
 private static void NotifyNewArrival(TwitterStatus status, NotificationType type, string explicitSoundSource)
 {
     Head.NotifyNewArrival(status, type, explicitSoundSource);
 }
예제 #51
0
 public NotificationData(SlimNotificationKind kind, TwitterStatus targetStatus)
 {
     this.Kind         = kind;
     this.TargetStatus = targetStatus;
 }
 private NewTwitterStatus(TwitterStatus twitterStatus)
 {
     this.twitterStatus = twitterStatus;
 }
예제 #53
0
        void backgroundWorkerBuildConversation_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            AccountTwitter account = AppController.Current.getAccountForId(startItem.accountId);

            if (!startItem.isDirectMessage)
            {
                #region Mention conversation
                decimal currentStatusId = startItem.InReplyToStatusId;
                while (currentStatusId != 0)
                {
                    if (account.Mentions.Where(i => i.Id == currentStatusId).Count() > 0)
                    {
                        TwitterItem knownMention = account.Mentions.Where(i => i.Id == currentStatusId).First() as TwitterItem;
                        if (knownMention != null)
                        {
                            currentStatusId = 0;
                            currentStatusId = knownMention.InReplyToStatusId;
                            backgroundWorkerBuildConversation.ReportProgress(100, knownMention);
                        }
                    }
                    else if (account.Timeline.Where(i => i.Id == currentStatusId).Count() > 0)
                    {
                        TwitterItem knownTimeline = account.Timeline.Where(i => i.Id == currentStatusId).First() as TwitterItem;
                        if (knownTimeline != null)
                        {
                            currentStatusId = 0;
                            currentStatusId = knownTimeline.InReplyToStatusId;
                            backgroundWorkerBuildConversation.ReportProgress(100, knownTimeline);
                        }
                    }
                    else
                    {
                        GetTweetOptions options = new GetTweetOptions();
                        options.Id = Convert.ToInt64(currentStatusId);
                        TwitterStatus status = startItem.RetrievingAccount.twitterService.GetTweet(options);

                        currentStatusId = 0;
                        if (status != null)
                        {
                            TwitterItem newItem = API.TweetSharpConverter.getItemFromStatus(status, startItem.RetrievingAccount);
                            if (newItem != null)
                            {
                                backgroundWorkerBuildConversation.ReportProgress(100, newItem);
                                currentStatusId = newItem.InReplyToStatusId;
                            }
                        }
                    }
                }

                // future entries
                currentStatusId = startItem.Id;

                List <TwitterItem> allItems = new List <TwitterItem>();
                foreach (IItem item in account.Mentions)
                {
                    allItems.Add(item as TwitterItem);
                }
                foreach (IItem item in account.Timeline)
                {
                    allItems.Add(item as TwitterItem);
                }

                List <decimal> multipleQueue = new List <decimal>();

                while (currentStatusId != 0)
                {
                    if (allItems.Where(i => i.InReplyToStatusId == currentStatusId).Count() > 0)
                    {
                        IEnumerable <TwitterItem> knownItems = allItems.Where(i => i.InReplyToStatusId == currentStatusId);
                        currentStatusId = 0;
                        foreach (TwitterItem item in knownItems)
                        {
                            if (item != null)
                            {
                                backgroundWorkerBuildConversation.ReportProgress(100, item);
                                if (currentStatusId == 0)
                                {
                                    currentStatusId = item.Id;
                                }
                                else
                                {
                                    multipleQueue.Add(item.InReplyToStatusId);
                                }
                            }
                        }
                    }
                    else
                    {
                        currentStatusId = 0;
                    }


                    if (currentStatusId == 0 && multipleQueue.Count() > 0)
                    {
                        currentStatusId = multipleQueue.First();
                        multipleQueue.RemoveAt(0);
                    }
                }
                #endregion
            }
            else
            {
                #region DM conversation

                List <TwitterItem> allDms = new List <TwitterItem>();
                foreach (IItem iitem in account.DirectMessages)
                {
                    allDms.Add(iitem as TwitterItem);
                }

                Person chatPartner;
                if (startItem.Author.Username == account.Login.Username)
                {
                    chatPartner = startItem.DMReceipient;
                }
                else
                {
                    chatPartner = startItem.Author;
                }

                IEnumerable <IItem> allOwnDMsInConversation = allDms.Where(i => i.DMReceipient.Username == chatPartner.Username);
                foreach (TwitterItem item in allOwnDMsInConversation)
                {
                    if (item != startItem)
                    {
                        backgroundWorkerBuildConversation.ReportProgress(100, item);
                    }
                }

                IEnumerable <IItem> allRecDMsInConversation = allDms.Where(i => i.Author.Username == chatPartner.Username);
                foreach (TwitterItem item in allRecDMsInConversation)
                {
                    if (item != startItem)
                    {
                        backgroundWorkerBuildConversation.ReportProgress(100, item);
                    }
                }

                #endregion
            }
        }
        public ActionResult View(int id)
        {
            TwitterStatus twitterStatus = Repository.GetStatusById(id);

            return(View(twitterStatus));
        }
예제 #55
0
        private void ProcessTweet(TwitterStatus Tweet)
        {
            String tweetText = Tweet.Text.Trim().ToLower();

            if (!tweetText.Contains(userdata.PCname))
            {
                return;
            }

            if (tweetText.Contains("shutdown"))
            {
                ProcessTweetShutdown("-s -f -t 30"); // Shutdown
            }
            else if (tweetText.Contains("restart"))
            {
                ProcessTweetShutdown("-r -f -t 30"); // Restart
            }
            else if (tweetText.Contains("logoff"))
            {
                ProcessTweetShutdown("-l -f -t 30"); // Logoff
            }
            else if (tweetText.Contains("hibernate"))
            {
                ProcessTweetSuspend(PowerState.Hibernate);
            }
            else if (tweetText.Contains("standby")
                    || tweetText.Contains("sleep"))
            {
                ProcessTweetSuspend(PowerState.Suspend);
            }
        }
예제 #56
0
        private void ApplyPatternCard(Contact contact, TwitterStatus tweet, PatternCard patternCard)
        {
            using (var client = XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient())
            {
                try
                {
                    // Get updated contact with ContactBehaviorProfile facet
                    var updatedContact = client.Get(new IdentifiedContactReference("twitter", tweet.User.ScreenName),
                                                    new ContactExpandOptions(ContactBehaviorProfile.DefaultFacetKey));
                    if (updatedContact == null)
                    {
                        return;
                    }

                    // Retrieve facet or create new
                    var isNewFacet = false;
                    var facet      =
                        updatedContact.GetFacet <ContactBehaviorProfile>(ContactBehaviorProfile.DefaultFacetKey);
                    if (facet == null)
                    {
                        isNewFacet = true;
                        facet      = new ContactBehaviorProfile();
                    }

                    // Change facet properties
                    var score = new ProfileScore {
                        ProfileDefinitionId = patternCard.GetProfile().ID.ToGuid()
                    };
                    if (score.Values == null)
                    {
                        score.Values = new Dictionary <Guid, double>();
                    }
                    var patterns = patternCard.GetPatterns();
                    foreach (var pair in patterns)
                    {
                        score.Values.Add(pair.Key, pair.Value);
                    }

                    if (facet.Scores.ContainsKey(patternCard.GetProfile().ID.Guid))
                    {
                        facet.Scores[patternCard.GetProfile().ID.Guid] = score;
                    }
                    else
                    {
                        facet.Scores.Add(patternCard.GetProfile().ID.Guid, score);
                    }

                    // Save the facet
                    if (isNewFacet)
                    {
                        client.SetFacet <ContactBehaviorProfile>(updatedContact, ContactBehaviorProfile.DefaultFacetKey, facet);
                    }
                    else
                    {
                        client.SetFacet(updatedContact, ContactBehaviorProfile.DefaultFacetKey, facet);
                    }

                    client.Submit();
                }
                catch (XdbExecutionException ex)
                {
                    Diagnostics.Log.Error(
                        $"[HashTagMonitor] Error applying Patter Card to Contact '{contact.Personal().Nickname}'",
                        ex, GetType());
                }
            }
        }
예제 #57
0
 /// <summary>
 /// Create StreamingEvent
 /// </summary>
 public StreamingEvent(TwitterStatus tstatus)
 {
     this.Kind = ElementKind.Status;
     this.Status = tstatus;
     this.SourceUser = tstatus.User;
 }
예제 #58
0
 public ActionResult <TwitterStatus> AddTwitterStatusToMongoDb(TwitterStatus twitterStatus)
 {
     _mongoDbServicer.Create(twitterStatus);
     return(CreatedAtRoute("GetTwitterStatus", new { id = twitterStatus.Id }, twitterStatus));
 }
예제 #59
0
 private void SendTweetInfo(IrcClient client, IList <IIrcMessageTarget> targets, TwitterStatus tweet)
 {
     client.LocalUser.SendMessage(targets, "@{0}: {1}", tweet.User.ScreenName,
                                  SanitizeTextForIrc(tweet.Text));
 }
예제 #60
0
 private StatusModel(TwitterStatus status, StatusModel retweetedOriginal)
     : this(status)
 {
     RetweetedStatus = retweetedOriginal;
 }