예제 #1
0
파일: Program.cs 프로젝트: ge0metrix/ytbot
        private static async Task Run(string[] args)
        {
            string token   = args[0];
            string logfile = args[1];
            string aikey   = args[2];
            string aiend   = args[3];

            using (var bot = new SlackBot(token)){
                bot.AddHandler(new PingHandler());
                //bot.AddHandler(new MessageHandler());
                bot.AddHandler(new MessageHandler(logfile));
                bot.AddHandler(new AnalyticsHandler(aikey, aiend));

                await bot.Connect().ConfigureAwait(false);

                Console.WriteLine("Connected");
                await WaitForKeyPress().ConfigureAwait(false);
            }
        }
예제 #2
0
        public async Task AddHandler_HandlesMessages()
        {
            var handler = Substitute.For <IMessageHandler>();

            await Connect();

            _sut.AddHandler(handler);
            _incomingMessages.OnNext(new MessageEvent {
                Text = "foo"
            });

            await handler.Received().HandleMessage(Arg.Is <IMessage>(m => m.Text == "foo"));
        }
예제 #3
0
        private static async Task Run(string token)
        {
            using (var bot = new SlackBot(token))
            {
                bot.AddHandler(new PingHandler());

                await bot.Connect().ConfigureAwait(false);

                Console.WriteLine("Connected");

                await WaitForKeyPress().ConfigureAwait(false);
            }
        }