Skip to content

.NET SDK for Mattermost v4 API with WebSocket real-time updates

License

Notifications You must be signed in to change notification settings

bvdcode/Mattermost.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Nuget Static Badge GitHub Actions Workflow Status NuGet version (Mattermost.NET) CodeFactor GitHub repo size

Mattermost.NET

Ready-to-use .NET Standard library for convenient development of Mattermost bots.

Getting Started

Installation

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

Usage

Create a new bot

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);

Subscribe to post updates

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!");
}

Start the bot

await client.StartReceivingAsync();

Stop the bot

await client.StopReceivingAsync();

Client Methods

SendMessageAsync

await client.SendMessageAsync("channel_id", "Hello, World!");

GetChannelMembersAsync

var members = await client.GetChannelMembersAsync("channel_id");

GetChannelPostsAsync

var posts = await client.GetChannelPostsAsync("channel_id");

... and more methods will be documented soon.

License

Distributed under the MIT License. See LICENSE.md for more information.

Contact

E-Mail

About

.NET SDK for Mattermost v4 API with WebSocket real-time updates

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages