Skip to content

Commit e642eb5

Browse files
Release 1.3 (#3)
* Allow all messages in private chats * Update logging * Fix docker-compose file formatting
1 parent 80b2bc2 commit e642eb5

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

docker-compose.dev.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ x-host-config: &host_config
1313

1414
services:
1515
host:
16-
<< : *restart_policy
17-
<< : *host_config
16+
<< : [*restart_policy, *host_config]
1817
build:
1918
context: .
2019
dockerfile: src/ElectricityOffNotifier.AppHost/Dockerfile

docker-compose.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ x-host-config: &host_config
1313

1414
services:
1515
host:
16-
<< : *restart_policy
17-
<< : *host_config
16+
<< : [*restart_policy, *host_config]
1817
build:
1918
context: .
2019
dockerfile: src/ElectricityOffNotifier.AppHost/Dockerfile

src/ElectricityOffNotifier.AppHost/Services/BotUpdateHandler.Commands.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ElectricityOffNotifier.AppHost.Services;
1111

1212
internal sealed partial class BotUpdateHandler
1313
{
14-
private static async Task HandleGetIdCommand(ITelegramBotClient botClient, long chatId, int? messageThreadId,
14+
private async Task HandleGetIdCommand(ITelegramBotClient botClient, long chatId, int? messageThreadId,
1515
int messageId, CancellationToken cancellationToken)
1616
{
1717
var messageBuilder = new StringBuilder();
@@ -30,9 +30,9 @@ await botClient.SendTextMessageAsync(
3030
replyToMessageId: messageId,
3131
cancellationToken: cancellationToken);
3232
}
33-
catch
33+
catch (Exception ex)
3434
{
35-
// silent
35+
_logger.LogDebug(ex, "Error occurred while sending Telegram message");
3636
}
3737
}
3838

@@ -340,7 +340,7 @@ await botClient.SendTextMessageAsync(chatId,
340340
}
341341
catch (Exception ex)
342342
{
343-
_logger.LogError(ex, "Error occurred while fetching the chat member");
343+
_logger.LogDebug(ex, "Error occurred while fetching the chat member");
344344
return;
345345
}
346346

src/ElectricityOffNotifier.AppHost/Services/BotUpdateHandler.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public async Task HandleUpdateAsync(ITelegramBotClient botClient, Update update,
4545
botClient.BotId, update.Message.Text);
4646

4747
string? botTokenById = _botAccessor.GetTokenByBotId(botClient.BotId.GetValueOrDefault());
48-
if (botTokenById != null)
48+
if (botTokenById != null && update.Message.Chat.Type != ChatType.Private)
4949
{
5050
_logger.LogDebug("Non-default token is registered for bot {BotId} in chat {ChatId}",
5151
botClient.BotId, chatId);
@@ -86,7 +86,7 @@ public async Task HandleUpdateAsync(ITelegramBotClient botClient, Update update,
8686
}
8787
catch (Exception ex)
8888
{
89-
_logger.LogDebug(ex, "Unable to get the chat member {UserId} in chat {ChatId}", fromId, chatId);
89+
_logger.LogWarning(ex, "Unable to get the chat member {UserId} in chat {ChatId}", fromId, chatId);
9090
return;
9191
}
9292
}
@@ -155,7 +155,8 @@ await HandleTemplateCommandWithReply(botClient, replyMessageText, chatId, messag
155155
MessageId: var messageId,
156156
MessageThreadId: var messageThreadId
157157
}
158-
}:
158+
}
159+
when isAdmin:
159160
{
160161
await HandleInfoCommand(botClient, currentChat, chatId, messageThreadId, messageId, context, isAdmin,
161162
cancellationToken);

src/ElectricityOffNotifier.AppHost/appsettings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
"LogLevel": {
1313
"Default": "Warning",
1414
"ElectricityOffNotifier.AppHost.Services": "Information",
15-
"Microsoft.AspNetCore.DataProtection": "Error",
16-
"ElectricityOffNotifier.AppHost.Services.BotUpdateHandler": "Debug"
15+
"Microsoft.AspNetCore.DataProtection": "Error"
1716
}
1817
}
1918
},

0 commit comments

Comments
 (0)