-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Arius Bronte edited this page Feb 24, 2020
·
3 revisions
VkNet.FluentCommands.GroupBot is a library that will allow you to create your bot in just a couple of minutes.
This library is suitable for beginners in programming, for people who need to quickly implement a bot, for small and medium-sized projects.
Install package vid Nuget. Package Manager
PM> Install-Package VkNet.FluentCommands.GroupBot
.NET CLI
> dotnet add package VkNet.FluentCommands.GroupBot
First connect the library in your namespace.
using VkNet.FluentCommands.GroupBot;
Next, create an instance of the FluentGroupBotCommands to authorize in and add triggers.
FluentGroupBotCommands commands = new FluentGroupBotCommands();
Add the group ID to the config.
commands.ConfigureGroupLongPoll(000000U);
Authorize.
await commands.InitBotAsync("very big group token");
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();