private static void Main(string[] args) { var configuration = BotConfigurationFactory.ReadConfiguration(); var connector = new SlackConnector.SlackConnector(); var connection = connector.Connect(configuration.SlackToken) .GetAwaiter() .GetResult(); var bot = new SlackerBot(connection); connection.OnMessageReceived += bot.OnMessageReceived; connection.OnUserJoined += bot.OnUserJoined; connection.OnDisconnect += bot.OnDisconnected; connection.OnReconnect += bot.OnReconnect; Console.ReadKey(); }
public async Task Connect() { string slackKey = this._configReader.SlackApiKey; var connector = new SlackConnector.SlackConnector(); this._connection = await connector.Connect(slackKey); this._connection.OnMessageReceived += this.MessageReceived; this._connection.OnDisconnect += this.OnDisconnect; this._connection.OnReconnecting += this.OnReconnecting; this._connection.OnReconnect += this.OnReconnect; this._logger.LogInformation("Connected!"); this._logger.LogInformation($"Bots Name: {this._connection.Self.Name}"); this._logger.LogInformation($"Team Name: {this._connection.Team.Name}"); this._container.GetPlugin <StatsPlugin>()?.RecordStat("Connected:Since", DateTime.Now.ToString("G")); this._container.GetPlugin <StatsPlugin>()?.RecordStat("Response:Average", this._averageResponse); this.StartPlugins(); }