One VC bot, one C # and an orange
- Tutorial

So, decompose on shelves.
- Для создания бота идем сюда
Нажимаем «создать приложение» и выбираем «Standalone Application». - Теперь переходим в управление и во вкладке Application Id запоминаем его Id. Оно нам дальше пригодится.

- Отправляем запрос, просто вставляя в браузерную строку:
https://oauth.vk.com/authorize?client_id=YOURAPPID&group_ids=YOURGROUPID6&display=page&scope=messages,wall,manage&response_type=token&v=5.92
где YOURAPPID — id приложения, что мы нашли в предыдущем спойлере, а YOURGROUPID id — вашего сообщества. - Даем доступ приложению

- И получаем такой ответ
https://oauth.vk.com/blank.html#expires_in=0&access_token_YOURGROUPID=YOURTOKEN
Где токен будет очень длинной комбинацией латинских букв и цифр
- Заходим в увправление сообществом


- Идем во вкладку управления нашим сообществом.
- Api Usage и в нем LongPoll Api

- Event types (события), в них отмечаем нужные, для тестов я бы отметил все.
Go to the main part:
Run your favorite ide, create a console application on the net core.

Add VkNet
Но есть отличная поддержка здесь.

Log in using our token:
var api = new VkApi();
api.Authorize(new ApiAuthParams(){AccessToken =MyAppToken }); And in an endless loop we will receive updates.
while (true)
{
var s = api.Groups.GetLongPollServer(MyGroupId);
var poll = api.Groups.GetBotsLongPollHistory(
new BotsLongPollHistoryParams()
{Server = s.Server, Ts = s.Ts, Key = s.Key, Wait = 1});
}Check if something has come to us
if(poll?.Updates== null) continue;For all received data, we will find out if any of this is a message, if so, then we will print its contents.
foreach (var a in poll.Updates)
{
if (a.Type == GroupUpdateType.MessageNew)
{
Console.WriteLine(a.Message.Body);
}
}And answer the user with the same text
api.Messages.Send(new MessagesSendParams()
{
UserId = a.Message.UserId,
Message = a.Message.Body
});classProgram
{
publicstaticstring MyAppToken =>
"f6bf5e26*************************************************************";
publicstaticulong MyGroupId => 10******;
staticvoidMain(string[] args)
{
var api = new VkApi();
api.Authorize(new ApiAuthParams(){AccessToken =MyAppToken });
while (true)
{
var s = api.Groups.GetLongPollServer(MyGroupId);
var poll = api.Groups.GetBotsLongPollHistory(
new BotsLongPollHistoryParams()
{Server = s.Server, Ts = s.Ts, Key = s.Key, Wait = 1});
if(poll?.Updates== null) continue;
foreach (var a in poll.Updates)
{
if (a.Type == GroupUpdateType.MessageNew)
{
Console.WriteLine(a.Message.Body);
api.Messages.Send(new MessagesSendParams()
{
UserId = a.Message.UserId,
Message = a.Message.Body
});
}
}
}
}
}Collect the resulting code for our board
dotnet publish . -r linux-armAnd we drag the necessary directory to the board. We go

via ssh and run
chmod +x ConsoleApp1
./ConsoleApp1

Получаем сообщение в консоли

Получаем ответ

Диалог
