示例#1
0
        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.
        }
示例#2
0
        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.
        }
示例#3
0
        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_connect_driver_should_connect()
        {
            var bot = new RocketChatBot(_driverMock, _loggerMock);

            // Act
            await bot.ConnectAsync();

            // Assert
            await _driverMock.Received().ConnectAsync();
        }