public static void Main(string[] args) { MessageHandler[] messageHandlers = new MessageHandler[] { new HealthCheckMessageHandler(), new HelloMessageHandler(), new PingMessageHandler() }; using (SlackBot slackBot = new SlackBot(ApplicationConfiguration.SlackBotApiToken, messageHandlers)) { slackBot.Start(); while (Console.ReadLine() != "Close") { } } Console.WriteLine("Boo!"); }
private static void Run(string baseUrl, string dataView, string username, string password, string slackToken) { OrbitApiClient apiClient = new OrbitApiClient(dataView, new ApiConnectorFactory(baseUrl)); if (!apiClient.Login(username, password)) { throw new Exception("Can't log in to the dataview " + dataView + " with username " + username + " using the API at " + baseUrl); } OrbitResponseHandler responseHandler = new OrbitResponseHandler(apiClient); SlackBot bot = new SlackBot(new SlackClientFactory(), responseHandler, new ConsoleLogger(), slackToken); bot.Start(); System.Console.WriteLine("Orbit Slackbot started. Press return to stop"); System.Console.WriteLine(); System.Console.ReadLine(); bot.Stop(); }
protected override void OnStart(string[] args) { base.OnStart(args); EnsureOrbitConnectionParametersCorrect(); logger.Log("Starting Orbit Slackbot - connecting to Orbit API"); OrbitApiClient apiClient = new OrbitApiClient(dataView, new ApiConnectorFactory(baseUrl)); if (!apiClient.Login(username, password)) { throw new Exception("Can't log in to the dataview " + dataView + " with username " + username + " using the API at " + baseUrl); } logger.Log("Starting Orbit Slackbot - successfully connected to Orbit API"); OrbitResponseHandler responseHandler = new OrbitResponseHandler(apiClient); logger.Log("Starting Orbit Slackbot - connecting to Slack"); bot = new SlackBot(new SlackClientFactory(), responseHandler, logger, slackToken); bot.Start(); logger.Log("Successfully started Orbit Slackbot"); }