Не отвечает бот в телеграмме C#
Я написал бота который высылает ссылку на группу в телеграмме, но при запуске он не реагирует не на какие команды, он работает через раз. что можно сделать?
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Stripe;
using Stripe.Checkout;
using Telegram.Bot;
using Telegram.Bot.Types;
using System.Threading;
namespace ConsoleApp3
{
internal class Program
{
static void Main(string[] args)
{
StripeConfiguration.ApiKey = "MY_TOKEN";
TelegramBotClient tgbot = new TelegramBotClient("MY_TOKEN");
tgbot.StartReceiving(update, error);
Console.ReadLine();
}
private static Task error(ITelegramBotClient arg1, Exception arg2, CancellationToken arg3)
{
throw new NotImplementedException();
}
private static async Task update(ITelegramBotClient botClient, Update updateeee, CancellationToken token)
{
Message msg = updateeee.Message;
long chatId = -941848938;
string inviteLink = await botClient.ExportChatInviteLinkAsync(chatId);
var options = new SessionCreateOptions
{
PaymentMethodTypes = new List<string>
{
"card",
"cashapp"
},
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
Currency = "usd",
UnitAmount = 20000,
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = "Проходка в чат",
Description = "Получаешь доступ к чату"
},
},
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
};
var service = new SessionService();
var session = service.Create(options);
if (msg.Text != null)
{
switch(msg.Text.ToLower())
{
case "/start":
await botClient.SendTextMessageAsync(msg.Chat.Id, "вот твоя ссылка для покупки: " + session.Url);
await botClient.SendTextMessageAsync(chatId, $"Вот ваша личная ссылка на вход в чат: {inviteLink}");
return;
}
}
}
}
}```