private static async Task MainAsync() { const string username = "******"; const string password = "******"; const string rocketServerUrl = "dev0:3000"; // just the host and port const bool useSsl = false; // Basically use ws or wss. // Create the bot - an abstraction of the driver RocketChatBot bot = new RocketChatBot(rocketServerUrl, useSsl); // Connect to Rocket.Chat await bot.ConnectAsync(); // Login ILoginOption loginOption = new EmailLoginOption { Email = username, Password = password }; await bot.LoginAsync(loginOption); // Start listening for messages await bot.SubscribeAsync(); // Add possible responses to be checked in order // This is not thead safe, FYI IBotResponse giphyResponse = new GiphyResponse(); bot.AddResponse(giphyResponse); // And that's it // Checkout GiphyResponse in the example project for more info. }
private static async void StartBot(ILoginOption option) { await bot.ConnectAsync(); await bot.LoginAsync(option); await bot.SubscribeAsync(() => new DirectResponseMessage(), () => new DirectResponseMessage()); }
public async Task On_subscribe_subscribe_to_all_rooms() { var bot = new RocketChatBot(_driverMock, _loggerMock); // Act await bot.SubscribeAsync(); // Assert await _driverMock.Received().SubscribeToRoomAsync(); }