private void FindUnvotes(Post post) { string pattern = "<strong>unvote</strong>"; System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match( post.Text, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase); if (match.Success) { //Is the poster already voting? If they are, remove their vote if (RawVoteCount.Contains(post.Poster)) { RawVoteCount.Remove(post.Poster); } } }
private void FindVotes(Post post) { string pattern = "<strong>(?:unvote[,.]?)? ?vote:? (.+)</strong>"; System.Text.RegularExpressions.Match match = System.Text.RegularExpressions.Regex.Match( post.Text, pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase); if (match.Success) { string vote = match.Groups[1].Value; string voter = post.Poster; if (IsVoterValid(voter)) { if (IsVoteeValid(vote, out string votee)) { //Is the poster already voting? If they are, remove their vote if (RawVoteCount.Contains(voter)) { RawVoteCount.Remove(voter); } //Add the vote to the votecount RawVoteCount.Add(voter, votee); logger.LogVote(post.PostNumber, voter, votee); } else { logger.LogInvalidTarget(post.PostNumber, voter, votee); } } else { logger.LogInvalidVoter(post.PostNumber, voter); } } }