예제 #1
0
        public async Task Connect_SetsIdAndName()
        {
            _rtm.Connect().Returns(new ConnectResponse {
                Self = new Self {
                    Id = "foo", Name = "bar"
                }
            });

            await _sut.Connect();

            _sut.Id.ShouldBe("foo");
            _sut.Name.ShouldBe("bar");
        }
예제 #2
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);
            }
        }
예제 #3
0
 private void Connect()
 {
     if (!_connected)
     {
         lock (_connectLock)
         {
             if (!_connected)
             {
                 _bot = SlackBot.Connect(_token).Result;
                 _bot.RegisterHandler(this);
                 _connected = true;
                 OnConnected();
             }
         }
     }
 }
예제 #4
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);
            }
        }