Created
April 21, 2012 08:11
-
-
Save mabster/2435527 to your computer and use it in GitHub Desktop.
Grammar bot v0.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var pattern = new Regex(@"(?:((c|sh|w)ould|might)\s+)of", RegexOptions.IgnoreCase); | |
var client = new TwitterAnonymousClient(); | |
long? last = null; | |
while (true) | |
{ | |
client.SearchAsync("\"should of\" OR \"would of\" OR \"could of\" OR \"might of\" -RT", since: last).ContinueWith(t => | |
{ | |
if (t.IsFaulted) return; | |
foreach (var tweet in t.Result.Result.OrderBy(s => s.Id)) | |
{ | |
last = tweet.Id; | |
Console.WriteLine(tweet.Text + "\n"); | |
var match = pattern.Match(tweet.Text); | |
if (!match.Success) continue; | |
{ | |
if (match.Groups.Count > 1) | |
{ | |
// eventually tweet this as a reply: | |
Console.WriteLine("It's not \"{0}\", it's \"{1} have\".\n\n", match.Groups[0].Value, match.Groups[1].Value); | |
} | |
} | |
} | |
}); | |
System.Threading.Thread.Sleep(10000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment