Skip to content

Commit

Permalink
Release 1.3 (#3)
Browse files Browse the repository at this point in the history
* Allow all messages in private chats

* Update logging

* Fix docker-compose file formatting
  • Loading branch information
vova-lantsov-dev authored Aug 19, 2023
1 parent 80b2bc2 commit e642eb5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
3 changes: 1 addition & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ x-host-config: &host_config

services:
host:
<< : *restart_policy
<< : *host_config
<< : [*restart_policy, *host_config]
build:
context: .
dockerfile: src/ElectricityOffNotifier.AppHost/Dockerfile
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ x-host-config: &host_config

services:
host:
<< : *restart_policy
<< : *host_config
<< : [*restart_policy, *host_config]
build:
context: .
dockerfile: src/ElectricityOffNotifier.AppHost/Dockerfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ElectricityOffNotifier.AppHost.Services;

internal sealed partial class BotUpdateHandler
{
private static async Task HandleGetIdCommand(ITelegramBotClient botClient, long chatId, int? messageThreadId,
private async Task HandleGetIdCommand(ITelegramBotClient botClient, long chatId, int? messageThreadId,
int messageId, CancellationToken cancellationToken)
{
var messageBuilder = new StringBuilder();
Expand All @@ -30,9 +30,9 @@ await botClient.SendTextMessageAsync(
replyToMessageId: messageId,
cancellationToken: cancellationToken);
}
catch
catch (Exception ex)
{
// silent
_logger.LogDebug(ex, "Error occurred while sending Telegram message");
}
}

Expand Down Expand Up @@ -340,7 +340,7 @@ await botClient.SendTextMessageAsync(chatId,
}
catch (Exception ex)
{
_logger.LogError(ex, "Error occurred while fetching the chat member");
_logger.LogDebug(ex, "Error occurred while fetching the chat member");
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task HandleUpdateAsync(ITelegramBotClient botClient, Update update,
botClient.BotId, update.Message.Text);

string? botTokenById = _botAccessor.GetTokenByBotId(botClient.BotId.GetValueOrDefault());
if (botTokenById != null)
if (botTokenById != null && update.Message.Chat.Type != ChatType.Private)
{
_logger.LogDebug("Non-default token is registered for bot {BotId} in chat {ChatId}",
botClient.BotId, chatId);
Expand Down Expand Up @@ -86,7 +86,7 @@ public async Task HandleUpdateAsync(ITelegramBotClient botClient, Update update,
}
catch (Exception ex)
{
_logger.LogDebug(ex, "Unable to get the chat member {UserId} in chat {ChatId}", fromId, chatId);
_logger.LogWarning(ex, "Unable to get the chat member {UserId} in chat {ChatId}", fromId, chatId);
return;
}
}
Expand Down Expand Up @@ -155,7 +155,8 @@ await HandleTemplateCommandWithReply(botClient, replyMessageText, chatId, messag
MessageId: var messageId,
MessageThreadId: var messageThreadId
}
}:
}
when isAdmin:
{
await HandleInfoCommand(botClient, currentChat, chatId, messageThreadId, messageId, context, isAdmin,
cancellationToken);
Expand Down
3 changes: 1 addition & 2 deletions src/ElectricityOffNotifier.AppHost/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"LogLevel": {
"Default": "Warning",
"ElectricityOffNotifier.AppHost.Services": "Information",
"Microsoft.AspNetCore.DataProtection": "Error",
"ElectricityOffNotifier.AppHost.Services.BotUpdateHandler": "Debug"
"Microsoft.AspNetCore.DataProtection": "Error"
}
}
},
Expand Down

0 comments on commit e642eb5

Please sign in to comment.