Skip to content
Arius Bronte edited this page Feb 25, 2020 · 2 revisions

What is it?

VkNet.FluentCommands.UserBot is a library that will allow you to create your bot in just a couple of minutes.

Who's it for?

This library is suitable for beginners in programming, for people who need to quickly implement a bot, for small and medium-sized projects.

Setup

Install package vid Nuget. Package Manager

PM> Install-Package VkNet.FluentCommands.UserBot

.NET CLI

> dotnet add package VkNet.FluentCommands.UserBot

Basic structure

First connect the library in your namespace.

using VkNet.FluentCommands.UserBot;

Next, create an instance of the FluentGroupBotCommands to authorize in and add triggers.

FluentUserBotCommands commands = new FluentUserBotCommands();

Authorize.

await commands.InitBotAsync("login", "very hard password");

Add commands.

commands.OnText("^ping$", "pong");
commands.OnText("^hello$", new[] {"hi!", "hey!", "good day!"});
commands.OnText("command not found");

Configure error handling. Is not required.

commands.OnException((e, token) =>
{
    Console.WriteLine("Wake up, everything is broken");
    Console.WriteLine($"[{DateTime.UtcNow}] {e.Message} {Environment.NewLine} {e.StackTrace}");
    return Task.CompletedTask;
});

Start receiving messages.

await commands.ReceiveMessageAsync();
Clone this wiki locally