Skip to content

Commit

Permalink
Less warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wiz0u committed Jul 11, 2024
1 parent dabaf50 commit 8efcde5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ dotnet_diagnostic.RCS1090.severity = none
# CA1848: Use the LoggerMessage delegates
dotnet_diagnostic.CA1848.severity = silent

# CA1307: Specify StringComparison for clarity
dotnet_diagnostic.CA1307.severity = silent

# CA1849: Call async methods when in an async method
dotnet_diagnostic.CA1849.severity = silent

# CA1304: Specify CultureInfo
dotnet_diagnostic.CA1304.severity = silent

# CA1311: Specify a culture or use an invariant version
dotnet_diagnostic.CA1311.severity = silent

# CA1310: Specify StringComparison for correctness
dotnet_diagnostic.CA1310.severity = silent

# IDE0062: Make local function 'static'
dotnet_diagnostic.IDE0062.severity = silent

# CA1062: Validate arguments of public methods
dotnet_diagnostic.CA1062.severity = silent

# CA1031: Do not catch general exception types
dotnet_diagnostic.CA1031.severity = silent

[*.md]
trim_trailing_whitespace = false
indent_size = 2
11 changes: 6 additions & 5 deletions Console.Advanced/Services/UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class UpdateHandler(ITelegramBotClient bot, ILogger<UpdateHandler> logger

public async Task HandleErrorAsync(ITelegramBotClient botClient, Exception exception, HandleErrorSource source, CancellationToken cancellationToken)
{
logger.LogInformation("HandleError: {exception}", exception);
logger.LogInformation("HandleError: {Exception}", exception);
// Cooldown in case of network connection error
if (exception is RequestException)
await Task.Delay(TimeSpan.FromSeconds(2));
await Task.Delay(TimeSpan.FromSeconds(2), cancellationToken);
}

public async Task HandleUpdateAsync(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken)
Expand Down Expand Up @@ -145,7 +145,7 @@ async Task<Message> SendAnonymousPoll(Message msg)

static Task<Message> FailingHandler(Message msg)
{
throw new IndexOutOfRangeException();
throw new NotImplementedException("FailingHandler");
}

// Process Inline Keyboard callback data
Expand Down Expand Up @@ -179,15 +179,16 @@ private async Task OnChosenInlineResult(ChosenInlineResult chosenInlineResult)

private Task OnPoll(Poll poll)
{
logger.LogInformation($"Received Pull info: {poll.Question}");
logger.LogInformation("Received Poll info: {Question}", poll.Question);
return Task.CompletedTask;
}

private async Task OnPollAnswer(PollAnswer pollAnswer)
{
var answer = pollAnswer.OptionIds.FirstOrDefault();
var selectedOption = PollOptions[answer];
await bot.SendTextMessageAsync(pollAnswer.User.Id, $"You've chosen: {selectedOption.Text} in poll");
if (pollAnswer.User != null)
await bot.SendTextMessageAsync(pollAnswer.User.Id, $"You've chosen: {selectedOption.Text} in poll");
}

private Task UnknownUpdateHandlerAsync(Update update)
Expand Down
11 changes: 6 additions & 5 deletions Webhook.Controllers/Services/UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class UpdateHandler(ITelegramBotClient bot, ILogger<UpdateHandler> logger

public async Task HandleErrorAsync(ITelegramBotClient botClient, Exception exception, HandleErrorSource source, CancellationToken cancellationToken)
{
logger.LogInformation("HandleError: {exception}", exception);
logger.LogInformation("HandleError: {Exception}", exception);
// Cooldown in case of network connection error
if (exception is RequestException)
await Task.Delay(TimeSpan.FromSeconds(2));
await Task.Delay(TimeSpan.FromSeconds(2), cancellationToken);
}

public async Task HandleUpdateAsync(ITelegramBotClient botClient, Update update, CancellationToken cancellationToken)
Expand Down Expand Up @@ -145,7 +145,7 @@ async Task<Message> SendAnonymousPoll(Message msg)

static Task<Message> FailingHandler(Message msg)
{
throw new IndexOutOfRangeException();
throw new NotImplementedException("FailingHandler");
}

// Process Inline Keyboard callback data
Expand Down Expand Up @@ -179,15 +179,16 @@ private async Task OnChosenInlineResult(ChosenInlineResult chosenInlineResult)

private Task OnPoll(Poll poll)
{
logger.LogInformation($"Received Pull info: {poll.Question}");
logger.LogInformation("Received Poll info: {Question}", poll.Question);
return Task.CompletedTask;
}

private async Task OnPollAnswer(PollAnswer pollAnswer)
{
var answer = pollAnswer.OptionIds.FirstOrDefault();
var selectedOption = PollOptions[answer];
await bot.SendTextMessageAsync(pollAnswer.User.Id, $"You've chosen: {selectedOption.Text} in poll");
if (pollAnswer.User != null)
await bot.SendTextMessageAsync(pollAnswer.User.Id, $"You've chosen: {selectedOption.Text} in poll");
}

private Task UnknownUpdateHandlerAsync(Update update)
Expand Down

0 comments on commit 8efcde5

Please sign in to comment.