Skip to content

Instantly share code, notes, and snippets.

@mabster
Created April 21, 2012 08:11
Show Gist options
  • Save mabster/2435527 to your computer and use it in GitHub Desktop.
Save mabster/2435527 to your computer and use it in GitHub Desktop.
Grammar bot v0.1
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