static void Main(string[] args) { SlackClient slackClient = new SlackClient(ConfigurationManager.AppSettings["oAuthTokenBot"]); slackClient.Connect(); try { string userId = slackClient.Users.Find(item => item.RealName.Contains("Orhan")).Id; string response = slackClient.ConnectRTM(); Pipeline pipeline = new Pipeline(); pipeline.Add(new WeatherMiddleware()); pipeline.Add(new QuoteMiddleware()); pipeline.Add(new StayHydratedMiddleware()); TimerPipeline timerPipeline = new TimerPipeline(); timerPipeline.Add(new StayHydratedTimerMiddleware()); var rtmClient = new RTMBot(new WebSocket(response), slackClient, pipeline, timerPipeline, 8); rtmClient.Connect(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
public RTMBot(WebSocket ws, SlackClient slackClient, Pipeline mainPipeline, TimerPipeline timerPipeline, int timerInterval) { _slackClient = slackClient; _ws = ws; // in case of overriding user specific event handlers _mainPipeline = mainPipeline; _timerPipeline = timerPipeline; _timer = new Timer(timerInterval * 1000); _timer.Elapsed += (sender, e) => { timerPipeline.Run(_slackClient); }; }