Ready-to-use .NET Standard library for convenient development of Mattermost bots.
The library is available as a NuGet package. You can install it using the NuGet Package Manager or the dotnet
CLI.
dotnet add package Mattermost.NET
using Mattermost.NET;
const string token = "37VlFKySIZn6gryA85cR1GKBQkjmfRZ6";
const string server = "https://mm.your-server.com"; // or https://community.mattermost.com by default
MattermostClient client = new(server, token);
client.OnMessageReceived += Client_OnMessageReceived;
private static void Client_OnMessageReceived(object? sender, MessageEventArgs e)
{
if (string.IsNullOrWhiteSpace(e.Message.Post.Text))
{
return;
}
e.Client.SendMessageAsync(e.Message.Post.ChannelId, "Hello, World!");
}
await client.StartReceivingAsync();
await client.StopReceivingAsync();
await client.SendMessageAsync("channel_id", "Hello, World!");
var members = await client.GetChannelMembersAsync("channel_id");
var posts = await client.GetChannelPostsAsync("channel_id");
...
and more methods will be documented soon.
Distributed under the MIT License. See LICENSE.md for more information.