public override Task ExecuteAsync(string generator, WebHookHandlerContext context) { NameValueCollection nvc; if (context.TryGetData <NameValueCollection>(out nvc)) { string question = nvc["subtext"]; string msg = string.Format("The answer to '{0}' is '{1}'.", question, "Often"); SlackResponse reply = new SlackResponse(msg); context.Response = context.Request.CreateResponse(reply); } return(Task.FromResult(true)); }
public override Task ExecuteAsync(string generator, WebHookHandlerContext context) { NameValueCollection nvc; if (context.TryGetData <NameValueCollection>(out nvc)) { string urlWithAccessToken = "https://hooks.slack.com/services/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"; SlackSend client = new SlackSend(urlWithAccessToken); string msg = ""; a = new developers { slackname = nvc["user_name"], lastpay = new date { day = "1", month = "1", year = "1" } }; string question = nvc["subtext"]; if (question == "yes") { breaklist.Add(a); tempbuuuulist.Remove(a); msg = "added " + breaklist.Count() + " " + tempbuuuulist.Count(); } else if (question == "no") { tempbuuuulist.Add(a); breaklist.Remove(a); msg = "removed " + breaklist.Count() + " " + tempbuuuulist.Count(); } else if (question == "status") { for (int i = 0; i < breaklist.Count(); i++) { msg += " " + breaklist[i].slackname + ""; } } else { Random rnd = new Random(); int num = rnd.Next(1, 7); if (num == 1) { msg = "pls .... Could you not"; } if (num == 2) { msg = "don't break me"; } if (num == 3) { msg = "I'm sorry " + a.slackname + ", i can't let you do that."; } if (num == 4) { msg = "leave breaky bot alone! :("; } if (num == 5) { msg = "Just what do you think you're doing, " + a.slackname + "?"; } if (num == 6) { msg = "we can talk about this"; } } msg += " " + a.slackname; SlackResponse reply = new SlackResponse(msg); context.Response = context.Request.CreateResponse(reply); } return(Task.FromResult(true)); }