Skip to content

RocketChat/Rocket.Chat.Net

 
 

Repository files navigation

Rocket.Chat.Net

Rocket.Chat.Net

Pre-release Stable Release
Rocket.Chat.Net NuGet NuGet
Rocket.Chat.Net.Bot NuGet NuGet

Build status Build status Coverage Status License Rocket.Chat Compatibility

A Rocket.Chat real-time, managed, .Net driver, and bot.

Not compatible with 0.36.0, 0.37.0, 0.37.1, see Silvenga#2 Waiting for things to settle down.

Driver Usage

const string username = "m@silvenga.com";
const string password = "silverlight";
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);

Bot Usage

const string username = "m@silvenga.com";
const string password = "silverlight";
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.

Building/Testing

docs/environment.md

Version compatibility changelogs

version-compatibility.md

Feature Support/TODO

docs/todo.md

About

A Rocket.Chat realtime managed .Net driver and bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.6%
  • PowerShell 0.4%