Exemplo n.º 1
0
        public IEnumerable <TwitterEntity> Coalesce()
        {
            var entities = new List <TwitterEntity>(Mentions.Count() + HashTags.Count() + Urls.Count() + Media.Count());

            entities.AddRange(Mentions.Cast <TwitterEntity>());
            entities.AddRange(HashTags.Cast <TwitterEntity>());
            entities.AddRange(Urls.Cast <TwitterEntity>());
            entities.AddRange(Media.Cast <TwitterEntity>());
            entities.Sort();

            return(entities);
        }
Exemplo n.º 2
0
        /// <summary>
        /// returns all mentions
        /// from the mentions list
        /// as well as the number of times
        /// they appear in the list
        /// </summary>
        /// <returns>strout</returns>
        public string getAllMentions()
        {
            string strout = "";
            var    q      = Mentions.GroupBy(x => x)
                            .Select(g => new { Value = g.Key, Count = g.Count() })
                            .OrderByDescending(x => x.Count);

            foreach (var m in q)
            {
                strout = strout + ("Mentions: " + m.Value + " Times mentioned: " + m.Count + "\n");
            }
            return(strout);
        }
Exemplo n.º 3
0
        public async Task Menciones()
        {
            try
            {
                List <Sebagomez.TwitterLib.Entities.Status> result = await Mentions.GetMentions(new MentionsOptions { User = m_user });

                Assert.True(result.Count > 0, "Ningún tweet!");
            }
            catch (Exception ex)
            {
                Assert.True(false, Util.ExceptionMessage(ex));
            }
        }
 public bool ToCsv(Mentions mentions)
 {
     try
     {
         string csv = $"{mentions.Users},{mentions.NofUsers.ToString()}";
         csv = csv + Environment.NewLine;
         File.AppendAllText(_csvFilePath, csv.ToString());
         return(true);
     }
     catch (Exception ex)
     {
         ErrorCode = ex.ToString();
         return(false);
     }
 }
 public void CheckContentForHashtagsAndMentions()
 {
     if (Content.Length > 0)
     {
         string[] contentWords = Content.Split(' ');
         foreach (var word in contentWords)
         {
             if (word.StartsWith('#'))
             {
                 Hashtags.Add(word);
             }
             if (word.StartsWith('@'))
             {
                 Mentions.Add(word);
             }
         }
     }
 }
Exemplo n.º 6
0
        public IEnumerable <TwitterEntity> Coalesce()
        {
#if !WINDOWS_PHONE
            var entities = new List <TwitterEntity>(Mentions.Count() + HashTags.Count() + Urls.Count());
            entities.AddRange((IEnumerable <TwitterEntity>)Mentions);
            entities.AddRange((IEnumerable <TwitterEntity>)HashTags);
            entities.AddRange((IEnumerable <TwitterEntity>)Urls);
            entities.Sort();
#else
            var entities = new List <TwitterEntity>(Mentions.Count() + HashTags.Count() + Urls.Count());
            entities.AddRange(Mentions.Cast <TwitterEntity>());
            entities.AddRange(HashTags.Cast <TwitterEntity>());
            entities.AddRange(Urls.Cast <TwitterEntity>());
            entities.Sort();
#endif

            return(entities);
        }
Exemplo n.º 7
0
 public void mentionsCallback(List <Post> posts, bool is_deleted = false)
 {
     if (posts != null)
     {
         foreach (Post post in posts)
         {
             if (post == null)
             {
                 continue;
             }
             if (post.machine_only || string.IsNullOrEmpty(post.text))
             {
                 continue;
             }
             if (!post.is_deleted)
             {
                 ApnItem item = new ApnItem(post, this);
                 item.receivingAccount = this;
                 Mentions.Add(item);
                 AppController.Current.sendNotification("App.net " + username + " mentions", item.AuthorName, item.Text, item.Avatar, item);
             }
             else
             {
                 IEnumerable <ApnItem> existing_items = Mentions.Where(item => item.Id.ToString() == post.id);
                 if (existing_items != null)
                 {
                     if (existing_items.Count() > 0)
                     {
                         List <ApnItem> cache = new List <ApnItem>();
                         foreach (ApnItem item in existing_items)
                         {
                             cache.Add(item);
                         }
                         foreach (ApnItem item in cache)
                         {
                             Mentions.Remove(item);
                         }
                         cache = null;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
        public async Task GetSearchForMentions()
        {
            if (Helper.Secrets == null)
            {
                return;
            }

            var mentionedUsers = await Mentions.GetSearchForMentionsAsync(Helper.Client, Helper.Kind, "yurucamp").ConfigureAwait(false);

            foreach (var value in mentionedUsers)
            {
                if (value.Undeserialized != null)
                {
                    throw new JsonException("Undeserialized is not empty");
                }
            }

            var json = JsonSerializer.Serialize(mentionedUsers, Core.Options);
        }
Exemplo n.º 9
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (RoomId?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Message?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ IsBot.GetHashCode();
         hashCode = (hashCode * 397) ^ (CreatedBy?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ CreatedOn.GetHashCode();
         hashCode = (hashCode * 397) ^ (EditedBy?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ EditedOn.GetHashCode();
         hashCode = (hashCode * 397) ^ IsBotMentioned.GetHashCode();
         hashCode = (hashCode * 397) ^ IsFromMyself.GetHashCode();
         hashCode = (hashCode * 397) ^ (Type?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ Mentions.GetHashCode();
         hashCode = (hashCode * 397) ^ Starred.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 10
0
        private void _processContent(Tweet tweet)
        {
            foreach (var hashtag in Util.Parse.GetHashtags(tweet.Content))
            {
                _hashtagService.UpdateHashtag(hashtag);
            }

            foreach (var mentionedUser in Util.Parse.GetMentions(tweet.Content))
            {
                var user = _userService.GetByUsernameOrDefault(mentionedUser);
                if (user != null)
                {
                    var mention = new Mentions {
                        MentionedUser   = user.Id,
                        MentioningTweet = tweet.Id
                    };

                    _context.Mentions.Add(mention);
                }
            }
        }
Exemplo n.º 11
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Id != null ? Id.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Text != null ? Text.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ImageUrl != null ? ImageUrl.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CreatedAt.GetHashCode();
         hashCode = (hashCode * 397) ^ (ButtonTitle != null ? ButtonTitle.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ButtonAction != null ? ButtonAction.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Author != null ? Author.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CommentsCount;
         hashCode = (hashCode * 397) ^ LikesCount;
         hashCode = (hashCode * 397) ^ IsLikedByMe.GetHashCode();
         hashCode = (hashCode * 397) ^ StickyStart.GetHashCode();
         hashCode = (hashCode * 397) ^ StickyEnd.GetHashCode();
         hashCode = (hashCode * 397) ^ (Mentions != null ? Mentions.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FeedId != null ? FeedId.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemplo n.º 12
0
        public ResponseVM PostReply(PostReply obj)
        {
            Tweets tweet = new Tweets
            {
                UserID    = obj.userID,
                Content   = obj.tweetContent,
                TweetDate = DateTime.Now,
                TweetImg  = obj.image
            };

            try
            {
                db.Tweets.Add(tweet);
                db.SaveChanges();

                Mentions mention = new Mentions
                {
                    TweetID        = obj.tweetID,
                    TweetMentionID = tweet.TweetID,
                    UserID         = obj.userID
                };

                db.Mentions.Add(mention);
                db.SaveChanges();

                return(new ResponseVM
                {
                    responseCode = 200,
                    responseMessage = "Reply posted successfully."
                });
            }
            catch (Exception)
            {
                return(new ResponseVM
                {
                    responseCode = 400,
                    responseMessage = "An error occurred."
                });
            }
        }
Exemplo n.º 13
0
        void IStreamingHandler.Streaming_StatusArrived(object sender, StatusArrivedEventArgs e)
        {
            StreamingClient c = sender as StreamingClient;

            _dispatcher.BeginInvoke(new EmptyDelegate(delegate() {
                if (!IsIncludeOtherStatus)
                {
                    if (!_client.FriendSet.Contains(e.Status.User.ID))
                    {
                        return;
                    }
                    if (e.Status.InReplyToUserId > 0)
                    {
                        if (!_client.FriendSet.Contains(e.Status.InReplyToUserId))
                        {
                            return;
                        }
                    }
                    if (e.Status.RetweetedStatus != null && e.Status.RetweetedStatus.User != null)
                    {
                        if (e.Status.RetweetedStatus.User.ID == SelfUserID)
                        {
                            return;
                        }
                    }
                }
                e.Status.AccountInfo = this;
                if (IsMention(e.Status))
                {
                    Mentions.Add(e.Status);
                    if (!_mgr.HomeIncludeMentions)
                    {
                        return;
                    }
                }
                HomeTimeline.Add(e.Status);
            }));
        }
Exemplo n.º 14
0
        void backgroundWorkerMentions_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e != null)
            {
                switch (e.ProgressPercentage)
                {
                case 50:
                    ApnItem item = e.UserState as ApnItem;
                    Mentions.Add(item);
                    if (showNotifications)
                    {
                        AppController.Current.sendNotification("App.net " + username + " mentions", item.AuthorName, item.Text, item.Avatar, item);
                    }
                    break;

                case 99:
                    ApiCallResponse apiCallResponse = e.UserState as ApiCallResponse;
                    streamMarkerMentionsUpdateComplete = true;
                    if (apiCallResponse != null)
                    {
                        if (apiCallResponse.meta != null)
                        {
                            if (apiCallResponse.meta.marker != null)
                            {
                                storeMarkerIdMentions      = apiCallResponse.meta.marker.id;
                                storeMarkerVersionMentions = apiCallResponse.meta.marker.version;
                            }
                        }
                    }
                    if (Mentions.Count > 0)
                    {
                        InitialUpdateForMention = true;
                    }
                    streamMarkerMentionsUpdateComplete = true;
                    break;
                }
            }
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            try
            {
                //Debug.Assert(false, "Attach VS here!");

                Console.OutputEncoding = new UTF8Encoding();

                PrintHeader();

                BaseAPI.SetMessageAction(message => Console.WriteLine(message));

                if (args.Length == 0)
                {
                    PrintTwits(Timeline.GetTimeline().Result);
                    return;
                }


                if (args[0].StartsWith("/"))
                {
                    string flag = args[0].ToLower().Trim();
                    switch (flag)
                    {
                    case CLEAR:
                        AuthenticatedUser.ClearCredentials();
                        Console.WriteLine("User credentials cleared!");
                        return;

                    case HELP:
                        ShowUsage();
                        return;

                    case TIME_LINE:
                        PrintTwits(Timeline.GetTimeline().Result);
                        return;

                    case MENTIONS:
                        PrintTwits(Mentions.GetMentions().Result);
                        return;

                    case SEARCH:
                        SearchOptions options = new SearchOptions {
                            Query = string.Join(" ", args).Substring(2), User = AuthenticatedUser.LoadCredentials()
                        };
                        PrintTwits(Search.SearchTweets(options).Result);
                        return;

                    case LIKES:
                        PrintTwits(Likes.GetUserLikes(new LikesOptions()).Result);
                        return;

                    case USER:
                        if (args.Length != 2)
                        {
                            throw new ArgumentNullException("screenname", "The user' screen name must be provided");
                        }
                        UserTimelineOptions usrOptions = new UserTimelineOptions {
                            ScreenName = args[1]
                        };
                        PrintTwits(UserTimeline.GetUserTimeline(usrOptions).Result);
                        return;

                    case STREAMING:
                        if (args.Length != 2)
                        {
                            throw new ArgumentNullException("streaming", "The track must be provided");
                        }
                        StreammingFilterOptions streamingOptions = new StreammingFilterOptions {
                            Track = args[1]
                        };
                        Console.WriteLine("Starting live streaming, press ctrl+c to quit");
                        foreach (Status s in StreamingFilter.GetStreamingTimeline(streamingOptions))
                        {
                            PrintTwit(s);
                        }
                        return;

                    default:
                        Console.WriteLine($"Invalid flag: {flag}");
                        ShowUsage();
                        return;
                    }
                }

                if (args[0].StartsWith("\\") || args[0].Length == 1)
                {
                    Console.WriteLine("Really? do you really wanna twit that?. [T]wit, or [N]o sorry, I messed up...");
                    ConsoleKeyInfo input = Console.ReadKey();
                    while (input.Key != ConsoleKey.T && input.Key != ConsoleKey.N)
                    {
                        Console.WriteLine();
                        Console.WriteLine("[T]wit, or [N]o sorry, I messed up...");
                        input = Console.ReadKey();
                    }
                    Console.WriteLine();

                    if (input.Key == ConsoleKey.N)
                    {
                        Console.WriteLine("That's what I thought! ;)");
                        return;
                    }
                }

                string response = Update.UpdateStatus(string.Join(" ", args)).Result;

                if (response != "OK")
                {
                    Console.WriteLine($"Response was not OK: {response}");
                }
            }
            catch (WebException wex)
            {
                Console.WriteLine(wex.Message);

                HttpWebResponse res = (HttpWebResponse)wex.Response;
                if (res != null)
                {
                    UpdateError errors = ShelltwitLib.Helpers.Util.Deserialize <UpdateError>(res.GetResponseStream());
                    errors.errors.ForEach(e => Console.WriteLine(e.ToString()));
                }
            }
            catch (Exception ex)
            {
                PrintException(ex);
            }
            finally
            {
#if DEBUG
                if (Debugger.IsAttached)
                {
                    Console.WriteLine("Press <enter> to exit...");
                    Console.ReadLine();
                }
#endif
            }

            Environment.Exit(0);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Edit the Text of an existing comment with mentions
 /// </summary>
 /// <param name="newTextWithFormats">A string with format placeholders - same as in string.Format. Index in these should correspond to an index in the <paramref name="personsToMention"/> array.</param>
 /// <param name="personsToMention">A params array of <see cref="ExcelThreadedCommentPerson"/>. Their DisplayName property will be used to replace the format placeholders.</param>
 public void EditText(string newTextWithFormats, params ExcelThreadedCommentPerson[] personsToMention)
 {
     Mentions.Clear();
     MentionsHelper.InsertMentions(this, newTextWithFormats, personsToMention);
     _thread.OnCommentThreadChanged();
 }
        public override IReadOnlyList <string> MergedQualifiers()
        {
            var parameters = new List <string>();

            if (In != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "in:{0}",
                                             String.Join(",", In.Select(i => i.ToParameter()))));
            }

            if (Type != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "type:{0}",
                                             Type.ToParameter()));
            }

            if (Author.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "author:{0}", Author));
            }

            if (Assignee.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "assignee:{0}", Assignee));
            }

            if (Mentions.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "mentions:{0}", Mentions));
            }

            if (Commenter.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "commenter:{0}", Commenter));
            }

            if (Involves.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "involves:{0}", Involves));
            }

            if (State.HasValue)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "state:{0}", State.Value.ToParameter()));
            }

            if (Labels != null)
            {
                parameters.AddRange(Labels.Select(label => String.Format(CultureInfo.InvariantCulture, "label:{0}", label)));
            }

            if (Language != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "language:{0}", Language));
            }

            if (Created != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "created:{0}", Created));
            }

            if (Updated != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated));
            }
            if (Merged != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "merged:{0}", Merged));
            }
            if (Comments != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments));
            }

            if (User.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "user:{0}", User));
            }

            if (Repos.Any())
            {
                var invalidFormatRepos = Repos.Where(x => !x.IsNameWithOwnerFormat());
                if (invalidFormatRepos.Any())
                {
                    throw new RepositoryFormatException(invalidFormatRepos);
                }

                parameters.Add(
                    string.Join("+", Repos.Select(x => "repo:" + x)));
            }

            return(new ReadOnlyCollection <string>(parameters));
        }
        public IReadOnlyList <string> MergedQualifiers()
        {
            var parameters = new List <string>();

            if (Author.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-author:{0}", Author));
            }

            if (Assignee.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-assignee:{0}", Assignee));
            }

            if (Mentions.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-mentions:{0}", Mentions));
            }

            if (Commenter.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-commenter:{0}", Commenter));
            }

            if (Involves.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-involves:{0}", Involves));
            }

            if (State.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-state:{0}", State.Value.ToParameter()));
            }

            if (Labels != null)
            {
                parameters.AddRange(Labels.Select(label => string.Format(CultureInfo.InvariantCulture, "-label:{0}", label)));
            }

            if (Language != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-language:{0}", Language.ToParameter()));
            }

            if (Status.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-status:{0}", Status.Value.ToParameter()));
            }

            if (Head.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-head:{0}", Head));
            }

            if (Base.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-base:{0}", Base));
            }

            if (Milestone.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "-milestone:\"{0}\"", Milestone.EscapeDoubleQuotes()));
            }

            return(new ReadOnlyCollection <string>(parameters));
        }
Exemplo n.º 19
0
        public override string ToString()
        {
            StringBuilder __sb    = new StringBuilder("AFActivity(");
            bool          __first = true;

            if (Id != null && __isset.id)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Id: ");
                __sb.Append(Id);
            }
            if (Content != null && __isset.content)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Content: ");
                __sb.Append(Content.ToDebugString());
            }
            if (ContentType != null && __isset.contentType)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("ContentType: ");
                __sb.Append(ContentType);
            }
            if (Reactions != null && __isset.reactions)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Reactions: ");
                __sb.Append(Reactions == null ? "<null>" : Reactions.ToString());
            }
            if (Properties != null && __isset.properties)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Properties: ");
                __sb.Append(Properties.ToDebugString());
            }
            if (Author != null && __isset.author)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Author: ");
                __sb.Append(Author == null ? "<null>" : Author.ToString());
            }
            if (__isset.createdAt)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("CreatedAt: ");
                __sb.Append(CreatedAt);
            }
            if (__isset.isAnnouncement)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("IsAnnouncement: ");
                __sb.Append(IsAnnouncement);
            }
            if (Mentions != null && __isset.mentions)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Mentions: ");
                __sb.Append(Mentions.ToDebugString());
            }
            if (Source != null && __isset.source)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Source: ");
                __sb.Append(Source);
            }
            if (Status != null && __isset.status)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("Status: ");
                __sb.Append(Status);
            }
            if (__isset.statusUpdatedAt)
            {
                if (!__first)
                {
                    __sb.Append(", ");
                }
                __first = false;
                __sb.Append("StatusUpdatedAt: ");
                __sb.Append(StatusUpdatedAt);
            }
            __sb.Append(")");
            return(__sb.ToString());
        }
 /// <summary>
 /// Retreives mentions of a user on the given connection
 /// </summary>
 /// <param name="u">The user for which to retreive the mentions</param>
 /// <param name="conn">The connection on which the query is run</param>
 /// <returns>Mentions (cached)</returns>
 public static async Task <Mentions> GetMentionsAsync(this Connection conn, User u)
 {
     return(await Mentions.InstanciateMentionsAsync(u, conn));
 }
Exemplo n.º 21
0
        public void getTwitterUserData(string user_name)
        {
            //List
            UserTimeline userTimelineChoreo = new UserTimeline(session);

            Show showChoreo = new Show(session);
            showChoreo.setScreenName(user_name);
            showChoreo.setAccessToken(accessToken);
            showChoreo.setAccessTokenSecret(accessTokenSecret);
            showChoreo.setConsumerSecret(consumer_secret);
            showChoreo.setConsumerKey(consumer_key);
            showChoreo.setIncludeEntities("false");

            // Get user date
            ShowResultSet showResults = showChoreo.execute();
            // Get user_id
            string s_user = showResults.Response;
            JObject json_user = JObject.Parse(s_user);
            string user_id = (string)json_user["id"];

            // Set inputs for user tweets
            userTimelineChoreo.setAccessToken(accessToken);
            userTimelineChoreo.setAccessTokenSecret(accessTokenSecret);
            userTimelineChoreo.setConsumerSecret(consumer_secret);
            userTimelineChoreo.setUserId(user_id);
            userTimelineChoreo.setConsumerKey(consumer_key);
            userTimelineChoreo.setCount("200");

            // Execute Choreo for users timeline tweets
            UserTimelineResultSet userTimelineResults = userTimelineChoreo.execute();

            //Create JSON objects
            string s_tweets = userTimelineResults.Response;
            string s2_tweets = "{\"statuses\":" + s_tweets + "}";
            processTweeting(s2_tweets, "");

            Mentions mentionsChoreo = new Mentions(session);

            // Set inputs for mentions

            mentionsChoreo.setAccessToken(accessToken);
            mentionsChoreo.setAccessTokenSecret(accessTokenSecret);
            mentionsChoreo.setConsumerSecret(consumer_secret);
            mentionsChoreo.setConsumerKey(consumer_key);

            // Get mentions
            MentionsResultSet mentionsResults = mentionsChoreo.execute();

            s_tweets = mentionsResults.Response;
            s2_tweets = "{\"statuses\":" + s_tweets + "}";
            processTweeting(s2_tweets, user_name);
        }
Exemplo n.º 22
0
 /// <summary>
 /// adds a mention to the mentions list
 /// </summary>
 /// <param name="mention"></param>
 public void addMentions(string mention)
 {
     Mentions.Add(mention);
 }
Exemplo n.º 23
0
        public override string ToString()
        {
#pragma warning disable 0618
            return(string.Format(
                       "Id: {0}, Text: {1}, HasText: {2}, ImageUrl: {3}, HasImage: {4}, CreatedAt: {5}, ButtonTitle: {6}, ButtonAction: {7}, Action: {8}, HasButton: {9}, Author: {10}, CommentsCount: {11}, LikesCount: {12}, IsLikedByMe: {13}, StickyStart: {14}, StickyEnd: {15}, FeedId: {16}, Mentions: {17}",
                       Id, Text, HasText, ImageUrl, HasImage, CreatedAt, ButtonTitle, ButtonAction, Action, HasButton, Author,
                       CommentsCount, LikesCount, IsLikedByMe, StickyStart, StickyEnd, FeedId, Mentions.ToDebugString()));

#pragma warning restore 0618
        }
Exemplo n.º 24
0
 /// <summary>
 /// Edit the Text of an existing comment
 /// </summary>
 /// <param name="newText"></param>
 public void EditText(string newText)
 {
     Mentions.Clear();
     Text = newText;
     _thread.OnCommentThreadChanged();
 }
Exemplo n.º 25
0
 public override string ToString()
 {
     return($"Id: {Id}, Text: {Text}, Author: {Author}, MediaAttachments: {MediaAttachments.ToDebugString()}, Type: {Type}, Announcement: {Announcement}, CommentsCount: {CommentsCount}, ReactionsCount: {ReactionsCount.ToDebugString()}, MyReactions: {MyReactionsList.ToDebugString()},  ViewCount: {ViewCount}, Properties: {Properties.ToDebugString()}, CreatedAt: {CreatedAt}, Mentions: {Mentions.ToDebugString()}, Button: {Button}, Source: {Source}, Status: {Status}");
 }
        //Processes Tweets
        private void ProcessTweet()
        {
            //Processes textspeak abbreviations and saves to ProcessedMessages.json
            Database.Textspeak_Abbreviations_Database.LoadTextspeakAbbreviations load = new Database.Textspeak_Abbreviations_Database.LoadTextspeakAbbreviations();

            var MessageHeaderText = MessageHeaderTextBox.ToString();
            var MessageBodyText   = MessageBodyTextBox.ToString();

            string[] splitMessageBodyText = MessageBodyTextBox.ToString().Split(' ');

            MessageBodyText = GetAbbreviations(MessageBodyText);

            MessagesProcessor msgProcessor = new MessagesProcessor()
            {
                msgType = MessageHeaderText,
                msgBody = MessageBodyText
            };

            File.AppendAllText("C:/VS Database/ProcessedMessages.json", JsonConvert.SerializeObject(msgProcessor));
            MessageBox.Show("Message Processed Successfully:" + Environment.NewLine + "Message Type - " + MessageHeaderText + Environment.NewLine + "Message Body - " + MessageBodyText);

            //Processes Mentions and saves to Mentions.csv
            Database.Mentions_Database.LoadMentionsFromFile load2 = new Database.Mentions_Database.LoadMentionsFromFile();
            Database.Mentions_Database.SaveMentionsToFile   save2 = new Database.Mentions_Database.SaveMentionsToFile();

            if (!load2.FromCSV())
            {
                MentionsList = new ObservableCollection <Mentions>();
            }
            else
            {
                MentionsList = new ObservableCollection <Mentions>(load2.MentionsList);

                var NofMentions = 0;
                for (int i = 2; i < splitMessageBodyText.Length; i++)
                {
                    var @char = splitMessageBodyText[i];
                    if (@char[0] == '@')
                    {
                        foreach (var Mentions in MentionsList)
                        {
                            if (Mentions.Users == splitMessageBodyText[i])
                            {
                                NofMentions = Mentions.NofUsers + 1;
                            }
                            else
                            {
                                NofMentions = 1;
                            }
                        }

                        Mentions mentions = new Mentions()
                        {
                            Users    = splitMessageBodyText[i],
                            NofUsers = NofMentions
                        };

                        if (!save2.ToCsv(mentions))
                        {
                            MessageBox.Show("Error while saving to mentions\n" + save2.ErrorCode);
                        }
                        else
                        {
                            save2 = null;
                        }
                    }
                }
            }

            //Processes Trending hashtags and adds it to Trending.csv
            Database.Trending_Database.LoadTrendingFromFile load3 = new Database.Trending_Database.LoadTrendingFromFile();
            Database.Trending_Database.SaveTrendingToFile   save3 = new Database.Trending_Database.SaveTrendingToFile();

            if (!load3.FromCSV())
            {
                TrendingList = new ObservableCollection <Trending>();
            }
            else
            {
                TrendingList = new ObservableCollection <Trending>(load3.TrendingList);

                var NofTrending = 0;
                for (int i = 2; i < splitMessageBodyText.Length; i++)
                {
                    var @char = splitMessageBodyText[i];
                    if (@char[0] == '#')
                    {
                        foreach (var Trending in TrendingList)
                        {
                            if (Trending.Hashtags == splitMessageBodyText[i])
                            {
                                NofTrending = Trending.NofHashtags + 1;
                            }
                            else
                            {
                                NofTrending = 1;
                            }
                        }

                        Trending trending = new Trending()
                        {
                            Hashtags    = splitMessageBodyText[i],
                            NofHashtags = NofTrending
                        };

                        if (!save3.ToCsv(trending))
                        {
                            MessageBox.Show("Error while saving to Trending\n" + save3.ErrorCode);
                        }
                        else
                        {
                            save2 = null;
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
        public override IReadOnlyList <string> MergedQualifiers()
        {
            var parameters = new List <string>();

            if (In != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "in:{0}",
                                             String.Join(",", In.Select(i => i.ToParameter()))));
            }

            if (Type != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "type:{0}",
                                             Type.ToParameter()));
            }

            if (Author.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "author:{0}", Author));
            }

            if (Assignee.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "assignee:{0}", Assignee));
            }

            if (Mentions.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "mentions:{0}", Mentions));
            }

            if (Commenter.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "commenter:{0}", Commenter));
            }

            if (Involves.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "involves:{0}", Involves));
            }

            if (State.HasValue)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "state:{0}", State.Value.ToParameter()));
            }

            if (Labels != null)
            {
                foreach (var label in Labels)
                {
                    parameters.Add(String.Format(CultureInfo.InvariantCulture, "label:{0}", label));
                }
            }

            if (Language != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "language:{0}", Language));
            }

            if (Created != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "created:{0}", Created));
            }

            if (Updated != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated));
            }

            if (Comments != null)
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments));
            }

            if (User.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "user:{0}", User));
            }

            if (Repo.IsNotBlank())
            {
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "repo:{0}", Repo));
            }

            return(new ReadOnlyCollection <string>(parameters));
        }
Exemplo n.º 28
0
        public override IReadOnlyList <string> MergedQualifiers()
        {
            var parameters = new List <string>();

            if (Type != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "type:{0}",
                                             Type.ToParameter()));
            }

            if (In != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "in:{0}",
                                             string.Join(",", In.Select(i => i.ToParameter()))));
            }

            if (Author.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "author:{0}", Author));
            }

            if (Assignee.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "assignee:{0}", Assignee));
            }

            if (Mentions.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "mentions:{0}", Mentions));
            }

            if (Commenter.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "commenter:{0}", Commenter));
            }

            if (Involves.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "involves:{0}", Involves));
            }

            if (Team.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "team:{0}", Team));
            }

            if (State.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "state:{0}", State.Value.ToParameter()));
            }

            if (Labels != null)
            {
                parameters.AddRange(Labels.Select(label => string.Format(CultureInfo.InvariantCulture, "label:{0}", label)));
            }

            if (No.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "no:{0}", No.Value.ToParameter()));
            }

            if (Language != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter()));
            }

            if (Is != null)
            {
                parameters.AddRange(Is.Select(x => string.Format(CultureInfo.InvariantCulture, "is:{0}", x.ToParameter())));
            }

            if (Created != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "created:{0}", Created));
            }

            if (Updated != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated));
            }

            if (Merged != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "merged:{0}", Merged));
            }

            if (Status.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "status:{0}", Status.Value.ToParameter()));
            }

            if (Head.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "head:{0}", Head));
            }

            if (Base.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "base:{0}", Base));
            }

            if (Closed != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "closed:{0}", Closed));
            }

            if (Comments != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments));
            }

            if (User.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "user:{0}", User));
            }

            if (Repos.Any())
            {
                var invalidFormatRepos = Repos.Where(x => !x.IsNameWithOwnerFormat());
                if (invalidFormatRepos.Any())
                {
                    throw new RepositoryFormatException(invalidFormatRepos);
                }

                parameters.AddRange(Repos.Select(x => string.Format(CultureInfo.InvariantCulture, "repo:{0}", x)));
            }

            // Add any exclusion parameters
            if (Exclusions != null)
            {
                parameters.AddRange(Exclusions.MergedQualifiers());
            }

            return(new ReadOnlyCollection <string>(parameters));
        }
Exemplo n.º 29
0
 private bool Equals(ActivityPost other)
 {
     return(string.Equals(Id, other.Id) && string.Equals(Text, other.Text) && string.Equals(ImageUrl, other.ImageUrl) && CreatedAt.Equals(other.CreatedAt) && string.Equals(ButtonTitle, other.ButtonTitle) && string.Equals(ButtonAction, other.ButtonAction) && Equals(Author, other.Author) && CommentsCount == other.CommentsCount && LikesCount == other.LikesCount && IsLikedByMe == other.IsLikedByMe && StickyStart.Equals(other.StickyStart) && StickyEnd.Equals(other.StickyEnd) && Mentions.ListEquals(other.Mentions) && string.Equals(FeedId, other.FeedId));
 }