Log messages translated into english and some punctuation fixes.

This commit is contained in:
Ruberoid 2025-07-22 00:04:52 +03:00
parent 96146e9dc2
commit 89fa1c845d
13 changed files with 24 additions and 24 deletions

View File

@ -24,7 +24,7 @@ public sealed class BotClient : Bot
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Bot can't initiate conversation with a user: {message}", message); _logger.LogError(ex, "Bot can't initiate conversation with a user: {message}.", message);
throw; throw;
} }
} }

View File

@ -19,7 +19,7 @@ public static class BotExtensions
} }
catch (Exception ex) catch (Exception ex)
{ {
logger?.LogWarning(ex, "Не удалось отредактировать текстовое сообщение"); logger?.LogWarning(ex, "Failed to edit text message.");
} }
await bot.SendMessageAsync(message, CancellationToken.None); await bot.SendMessageAsync(message, CancellationToken.None);

View File

@ -40,7 +40,7 @@ public sealed class MessageDispatcherHandler : IMessageDispatcherHandler
ex.Message.Equals("Forbidden: bot was blocked by the user", ex.Message.Equals("Forbidden: bot was blocked by the user",
StringComparison.OrdinalIgnoreCase)) StringComparison.OrdinalIgnoreCase))
{ {
_logger.LogWarning("Bot was blocked by user {ChatId}, marking user as blocked", tm.ChatId); _logger.LogWarning("Bot was blocked by user {ChatId}, marking user as blocked.", tm.ChatId);
try try
{ {
@ -51,16 +51,16 @@ public sealed class MessageDispatcherHandler : IMessageDispatcherHandler
await _usersService.BlockBot(user.Id, cancellationToken); await _usersService.BlockBot(user.Id, cancellationToken);
await _textMatcherService.DeactivateAllUserSubscriptions(user.Id, cancellationToken); await _textMatcherService.DeactivateAllUserSubscriptions(user.Id, cancellationToken);
_logger.LogInformation("Successfully blocked user {UserId} (ChatId: {ChatId}) and deactivated all subscriptions", user.Id, tm.ChatId); _logger.LogInformation("Successfully blocked user {UserId} (ChatId: {ChatId}) and deactivated all subscriptions.", user.Id, tm.ChatId);
} }
else else
{ {
_logger.LogWarning("Could not find user with ChatId {ChatId} to mark as blocked", tm.ChatId); _logger.LogWarning("Could not find user with ChatId {ChatId} to mark as blocked.", tm.ChatId);
} }
} }
catch (Exception blockEx) catch (Exception blockEx)
{ {
_logger.LogError(blockEx, "Failed to process user blocking for ChatId {ChatId}", tm.ChatId); _logger.LogError(blockEx, "Failed to process user blocking for ChatId {ChatId}.", tm.ChatId);
} }
} }
break; break;
@ -68,7 +68,7 @@ public sealed class MessageDispatcherHandler : IMessageDispatcherHandler
await _bot.SendAnimationAsync(am, cancellationToken); await _bot.SendAnimationAsync(am, cancellationToken);
break; break;
default: default:
_logger.LogWarning("Dequeued message has unsupported type: {Type}", typeof(Message).FullName); _logger.LogWarning("Dequeued message has unsupported type: {Type}.", typeof(Message).FullName);
break; break;
} }
} }

View File

@ -60,7 +60,7 @@ public abstract class StartHandlerBase
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogWarning(ex, "Failed to delete message {MessageId} in chat {ChatId}", messageId, chatId); _logger.LogWarning(ex, "Failed to delete message {MessageId} in chat {ChatId}.", messageId, chatId);
} }
} }

View File

@ -30,7 +30,7 @@ public class ActivateSubscriptionHandler : ViewSubscriptionHandlerBase, IMatchin
{ {
if (update.CallbackQuery is null) if (update.CallbackQuery is null)
{ {
_logger.LogError("Не удалось выделить пользовательский колбэк.\n{@Update}", update); _logger.LogError("Failed to extract user callback.\n{@Update}", update);
return; return;
} }
@ -40,7 +40,7 @@ public class ActivateSubscriptionHandler : ViewSubscriptionHandlerBase, IMatchin
if (callbackData.Args.Count != 1 || !long.TryParse(callbackData.Args.First(), out var subscriptionId)) if (callbackData.Args.Count != 1 || !long.TryParse(callbackData.Args.First(), out var subscriptionId))
{ {
_logger.LogWarning( _logger.LogWarning(
"Не удалось извлечь идентификатор подписки. CallbackData: {@CallbackData}, ChatId: {ChatId}, MessageId {MessageId}.", "Failed to extract subscription ID. CallbackData: {@CallbackData}, ChatId: {ChatId}, MessageId: {MessageId}.",
callbackData, from, update.CallbackQuery?.Message?.Chat.Id); callbackData, from, update.CallbackQuery?.Message?.Chat.Id);
SendErrorMessage(from); SendErrorMessage(from);
return; return;
@ -52,14 +52,14 @@ public class ActivateSubscriptionHandler : ViewSubscriptionHandlerBase, IMatchin
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Не удалось деактивировать подписку."); _logger.LogError(ex, "Failed to activate subscription.");
SendErrorMessage(from); SendErrorMessage(from);
throw; throw;
} }
if (update.CallbackQuery.Message is null) if (update.CallbackQuery.Message is null)
{ {
_logger.LogError("Не удалось выделить идентификатор сообщения из пользовательского колбэка.\n{@CallbackQuery}", update.CallbackQuery); _logger.LogError("Failed to extract message ID from user callback.\n{@CallbackQuery}", update.CallbackQuery);
return; return;
} }

View File

@ -51,7 +51,7 @@ public sealed class AddSubscriptionHandler : IMatchingUpdateHandler<AddSubscript
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogWarning(ex, "Failed to delete message {MessageId} in chat {ChatId}", messageId, chatId); _logger.LogWarning(ex, "Failed to delete message {MessageId} in chat {ChatId}.", messageId, chatId);
} }
_messageDispatcherQueue.Enqueue(message); _messageDispatcherQueue.Enqueue(message);

View File

@ -31,7 +31,7 @@ public class DeactivateSubscriptionHandler : ViewSubscriptionHandlerBase,
{ {
if (update.CallbackQuery?.Message is null) if (update.CallbackQuery?.Message is null)
{ {
_logger.LogError("Не удалось выделить пользовательский колбэк.\n{@Update}", update); _logger.LogError("Failed to extract user callback.\n{@Update}", update);
return; return;
} }
@ -41,7 +41,7 @@ public class DeactivateSubscriptionHandler : ViewSubscriptionHandlerBase,
if (callbackData.Args.Count != 1 || !long.TryParse(callbackData.Args.First(), out var subscriptionId)) if (callbackData.Args.Count != 1 || !long.TryParse(callbackData.Args.First(), out var subscriptionId))
{ {
_logger.LogWarning( _logger.LogWarning(
"Не удалось извлечь идентификатор подписки. CallbackData: {@CallbackData}, ChatId: {ChatId}, MessageId {MessageId}", "Failed to extract subscription ID. CallbackData: {@CallbackData}, ChatId: {ChatId}, MessageId: {MessageId}.",
callbackData, from, update.CallbackQuery.Message.Chat.Id); callbackData, from, update.CallbackQuery.Message.Chat.Id);
SendErrorMessage(from); SendErrorMessage(from);
return; return;
@ -53,7 +53,7 @@ public class DeactivateSubscriptionHandler : ViewSubscriptionHandlerBase,
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Не удалось деактивировать подписку"); _logger.LogError(ex, "Failed to deactivate subscription.");
SendErrorMessage(from); SendErrorMessage(from);
throw; throw;
} }

View File

@ -26,7 +26,7 @@ public class FeedbackHandler : IMatchingUpdateHandler<FeedbackMatcher>
{ {
if (update.CallbackQuery?.Message is null) if (update.CallbackQuery?.Message is null)
{ {
_logger.LogError("Не удалось выделить идентификатор сообщения из пользовательского колбэка.\n{@CallbackQuery}", update.CallbackQuery); _logger.LogError("Failed to extract message ID from user callback.\n{@CallbackQuery}", update.CallbackQuery);
return Task.CompletedTask; return Task.CompletedTask;
} }

View File

@ -73,7 +73,7 @@ public sealed class FeedbackMessageHandler : IMatchingUpdateHandler<FeedbackMess
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogWarning(ex, "Failed to send feedback message to {FeedbackReceiverId}", feedbackReceiverId); _logger.LogWarning(ex, "Failed to send feedback message to {FeedbackReceiverId}.", feedbackReceiverId);
} }
} }

View File

@ -28,7 +28,7 @@ public abstract class SubscribeHandlerBase : ViewSubscriptionHandlerBase
{ {
if (update.Message?.Text is null || update.Message?.From is null) if (update.Message?.Text is null || update.Message?.From is null)
{ {
_logger.LogError("Cannot parse update message or from/text user unknown. {@Update}", update.Id); _logger.LogError("Cannot parse update message or from/text user unknown. {@Update}.", update.Id);
_logger.LogDebug(update.ToString()); _logger.LogDebug(update.ToString());
return; return;
} }

View File

@ -27,14 +27,14 @@ public sealed class UpdateTelegramLoggingHandler : IUpdateHandler
public Task Handle(Update update, CancellationToken cancellationToken = default) public Task Handle(Update update, CancellationToken cancellationToken = default)
{ {
_logger.LogDebug("Received update:\n{@Update}", update); _logger.LogDebug("Received update:\n{@Update}.", update);
if (_options.EnableUpdateTelegramLogging) if (_options.EnableUpdateTelegramLogging)
{ {
var from = GetFrom(update); var from = GetFrom(update);
if (from == null) if (from == null)
{ {
_logger.LogWarning("Failed to extract `from` from update:\n{@Update}", update); _logger.LogWarning("Failed to extract `from` from update:\n{@Update}.", update);
return Task.CompletedTask; return Task.CompletedTask;
} }

View File

@ -35,7 +35,7 @@ public sealed class TextSubscriptionMatchedHandler : IHandleMessages<TextMatcher
var user = await _usersService.GetById(message.SubscriptionUserId); var user = await _usersService.GetById(message.SubscriptionUserId);
if (user == null) if (user == null)
{ {
_logger.LogWarning("User [{UserId}] of [{MatchId}] from message {MessageId} not found", _logger.LogWarning("User [{UserId}] of [{MatchId}] from message {MessageId} not found.",
message.SubscriptionUserId, message.SubscriptionUserId,
message.SubscriptionId, message.Id); message.SubscriptionId, message.Id);
return; return;
@ -44,7 +44,7 @@ public sealed class TextSubscriptionMatchedHandler : IHandleMessages<TextMatcher
var identity = user.Identities.FirstOrDefault(x => x.Type == UserIdentityType.TelegramId); var identity = user.Identities.FirstOrDefault(x => x.Type == UserIdentityType.TelegramId);
if (identity == null) if (identity == null)
{ {
_logger.LogWarning("There is no identity with type '{IdentityType}' for user '{UserId}'", _logger.LogWarning("There is no identity with type '{IdentityType}' for user '{UserId}'.",
UserIdentityType.TelegramId, user.Id); UserIdentityType.TelegramId, user.Id);
return; return;
} }

View File

@ -34,7 +34,7 @@ public abstract class RepeatableBackgroundService<THandler, TOptions> : Backgrou
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogCritical(ex, "Failed to process..."); _logger.LogCritical(ex, "Failed to process.");
await Task.Delay(_options.ExceptionInterval, stoppingToken); await Task.Delay(_options.ExceptionInterval, stoppingToken);
} }
} }