static void Main(string[] args) { var config = new HostConfiguration() { UrlReservations = new UrlReservations() { CreateAutomatically = true } }; using (var host = new NancyHost(config, new Uri("http://localhost:9012"))) { host.Start(); var oAuthToken = GetTokensAndShit.GetOAuthToken(); var authedClient = SlackClientStuff.GetSlackClient(oAuthToken); authedClient?.PostMessage( result => Console.WriteLine("Response was: " + JsonConvert.SerializeObject(result, Formatting.Indented)), Constants.CHANNEL_NAME, "Test!"); Console.WriteLine("Please press [Enter] to exit the application."); Console.ReadLine(); } }
public WebhookModule() { Get["/hello"] = parameters => "HI!"; Get["/"] = _ => { var code = Request.Query["code"]; var state = Request.Query["state"]; GetTokensAndShit.HereComesAResult(code, state); return("Processed"); }; Post["/"] = _ => { var model = this.Bind <Core.Models.HookMessage>(); var message = string.Empty; if (model.Text.ToLower().StartsWith("testbot: hello")) { message = string.Format("@{0} Hello", model.UserName); } if (!string.IsNullOrWhiteSpace(message)) { SlackClientStuff.IWantAClient().PostMessage(null, Core.Constants.CHANNEL_NAME, message); } return(null); }; }