Пример #1
0
        public async Task Run()
        {
            const string username        = "******";
            const string password        = "******";
            const string rocketServerUrl = "demo.rocket.chat:3000";
            const bool   useSsl          = false;

            ILoginOption loginOption = new LdapLoginOption
            {
                Username = username,
                Password = password
            };

            IRocketChatDriver driver = new RocketChatDriver(rocketServerUrl, useSsl);

            await driver.ConnectAsync();          // Connect to server

            await driver.LoginAsync(loginOption); // Login via LDAP

            await driver.SubscribeToRoomAsync();  // Listen on all rooms

            driver.MessageReceived += Console.WriteLine;

            var generalRoomIdResult = await driver.GetRoomIdAsync("general");

            if (generalRoomIdResult.HasError)
            {
                throw new Exception("Could not find room by name.");
            }

            var generalRoomId = generalRoomIdResult.Result;
            await driver.SendMessageAsync("message", generalRoomId);
        }
Пример #2
0
        static void Main(string[] args)
        {
            ILoginOption loginOption = new LdapLoginOption
            {
                Username = "******",
                Password = "******"
            };

            // SetUp Bot
            bot = new RocketChatBot("192.168.99.100:5888", false, new Microsoft.Extensions.Logging.Console.ConsoleLogger("Logger", (a, b) => true, true));

            bot.AddResponse(new TestResponse());

            StartBot(loginOption);

            Console.ReadLine();
        }
Пример #3
0
        public static async void Initialise(ChatContext context)
        {
            ILoginOption loginOption = new LdapLoginOption
            {
                Username = context.Username,
                Password = context.Password
            };

            IRocketChatDriver driver = new RocketChatDriver(context.RocketServerUrl, context.UseSSL);

            await driver.ConnectAsync();          // Connect to server

            await driver.LoginAsync(loginOption); // Login via LDAP

            await driver.SubscribeToRoomAsync();  // Listen on all rooms

            driver.MessageReceived += message =>
            {
                context.MessageRead?.Invoke(message);
            };
        }