public static void Main(string[] args) { var apiKey = ConfigurationManager.AppSettings["slackbot.apikey"]; using (var slackBot = SlackBot.Create(apiKey).Instantiate()) { slackBot.Start(); while (true) { char command = Console.ReadKey(true).KeyChar; if (command == 'q') { Console.WriteLine("Quitting..."); slackBot.Stop(); return; } if (command == 'r') { Console.WriteLine("Restarting..."); slackBot.Stop(); slackBot.Start(); } } } }
public void InstantiateBasicInstance() { var slackBot = SlackBot.Create("xxx") .WithoutCoreHandlers() .Instantiate(); Assert.NotNull(slackBot); Assert.Null(slackBot.MessageHandlers); Assert.Null(slackBot.SlackService); }
public void InstantiateInstanceWithCoreHandlers() { var slackBot = SlackBot.Create("xxx") .Instantiate(); Assert.NotNull(slackBot); Assert.NotNull(slackBot.MessageHandlers); Assert.NotNull(slackBot.SlackService); Assert.True(slackBot.MessageHandlers.Any(h => h.GetType() == typeof(RtmStartHandler))); }
public void InstantiateInstanceWithTypePlugin() { var slackBot = SlackBot.Create("xxx") .WithoutCoreHandlers() .WithPlugin <UserPingHandler>() .Instantiate(); Assert.NotNull(slackBot); Assert.True(slackBot.MessageHandlers.Count() == 1); Assert.NotNull(slackBot.SlackService); Assert.True(slackBot.MessageHandlers.First().GetType() == typeof(UserPingHandler)); }
public void InstantiateInstanceWithPluginPath() { var slackBot = SlackBot.Create("xxx") .WithoutCoreHandlers() .WithPluginPath("../../../DummyTestPlugins/Dll/") .Instantiate(); Assert.NotNull(slackBot); Assert.True(slackBot.MessageHandlers.Count() == 2); Assert.NotNull(slackBot.SlackService); Assert.True(slackBot.MessageHandlers.Any(h => h.GetType() == typeof(TestPlugin1))); Assert.True(slackBot.MessageHandlers.Any(h => h.GetType() == typeof(TestPlugin2))); }
public void InstantiateInstanceWithAssemblyPlugin() { var slackBot = SlackBot.Create("xxx") .WithoutCoreHandlers() .WithPluginAssembly(typeof(TestPlugin1).Assembly) .Instantiate(); Assert.NotNull(slackBot); Assert.True(slackBot.MessageHandlers.Count() == 2); Assert.NotNull(slackBot.SlackService); Assert.True(slackBot.MessageHandlers.Any(h => h.GetType() == typeof(TestPlugin1))); Assert.True(slackBot.MessageHandlers.Any(h => h.GetType() == typeof(TestPlugin2))); }