Example #1
0
        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();
                    }
                }
            }
        }
Example #2
0
        public void InstantiateBasicInstance()
        {
            var slackBot = SlackBot.Create("xxx")
                           .WithoutCoreHandlers()
                           .Instantiate();

            Assert.NotNull(slackBot);
            Assert.Null(slackBot.MessageHandlers);
            Assert.Null(slackBot.SlackService);
        }
Example #3
0
        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)));
        }
Example #4
0
        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));
        }
Example #5
0
        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)));
        }
Example #6
0
        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)));
        }