fix: remove comments

This commit is contained in:
Guillermo Marcel 2025-02-12 19:22:18 -03:00
parent 37f987d244
commit affae8ff48
2 changed files with 4 additions and 21 deletions

View File

@ -32,7 +32,7 @@ public class BotHandler
{ {
_logger.LogInformation("Starting bot..."); _logger.LogInformation("Starting bot...");
_bot = new TelegramBotClient(_botConfiguration.Token, cancellationToken: cancellationToken); _bot = new TelegramBotClient(_botConfiguration.Token, cancellationToken: cancellationToken);
// var me = await _bot.GetMe();
_bot.OnError += OnError; _bot.OnError += OnError;
_bot.OnMessage += OnMessage; _bot.OnMessage += OnMessage;
@ -69,11 +69,7 @@ public class BotHandler
await using var stream = File.OpenRead(@"C:\Users\GuillermoMarcel\Pictures\prueba.jpeg"); await using var stream = File.OpenRead(@"C:\Users\GuillermoMarcel\Pictures\prueba.jpeg");
var inputFile = InputFile.FromStream(stream, "gorda.jpeg"); var inputFile = InputFile.FromStream(stream, "gorda.jpeg");
// var message = await _bot.SendPhotoAsync(new ChatId(id), new InputOnlineFile(stream, "prueba.jpeg"));
// await _bot.SendDocument(new ChatId(id), document: inputFile, caption: "imagen de prueba");
// await _bot.SendPhoto(new ChatId(id),
// "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/6.png", "Wild charizard");
await _bot.SendPhoto(new ChatId(id), inputFile, "mi gorda"); await _bot.SendPhoto(new ChatId(id), inputFile, "mi gorda");
} }
@ -84,7 +80,7 @@ public class BotHandler
return Task.CompletedTask; return Task.CompletedTask;
} }
// method that handle messages received by the bot:
private async Task OnMessage(Message msg, UpdateType type) private async Task OnMessage(Message msg, UpdateType type)
{ {
if (_bot is null) if (_bot is null)

View File

@ -27,11 +27,6 @@ serviceCollection.AddSingleton<BotHandler>();
var serviceProvider = serviceCollection.BuildServiceProvider(); var serviceProvider = serviceCollection.BuildServiceProvider();
// var url = "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getMe";
// var token = ;
var botHandler = serviceProvider.GetService<BotHandler>(); var botHandler = serviceProvider.GetService<BotHandler>();
if (botHandler is null) if (botHandler is null)
{ {
@ -43,23 +38,15 @@ using var cts = new CancellationTokenSource();
botHandler.Start(cts.Token); botHandler.Start(cts.Token);
// call the bot handler to send a message every minute to the subscribers
_ = SendMessageToSubscribers(cts.Token); _ = SendMessageToSubscribers(cts.Token);
// var bot = new TelegramBotClient(token, cancellationToken: cts.Token);
// var me = await bot.GetMe();
//
// bot.OnError += OnError;
// bot.OnMessage += OnMessage;
// bot.OnUpdate += OnUpdate;
//
Console.WriteLine($"bot is running... Press Enter to terminate"); Console.WriteLine($"bot is running... Press Enter to terminate");
Console.ReadLine(); Console.ReadLine();
cts.Cancel(); // stop the bot cts.Cancel(); // stop the bot
return; return;
//async method to send a message to the subscribers every two minutes with the current time
async Task SendMessageToSubscribers(CancellationToken cancellationToken) async Task SendMessageToSubscribers(CancellationToken cancellationToken)
{ {
while (!cancellationToken.IsCancellationRequested) while (!cancellationToken.IsCancellationRequested)