forked from NET-Bootcamp-N11/BookStore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into LogAndDeploy
- Loading branch information
Showing
10 changed files
with
599 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/BookStore.Application/useCases/Extensions/TelegramBot/IWriteToTelegramBotService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BookStore.Application.useCases.Extensions.TelegramBot | ||
{ | ||
public interface IWriteToTelegramBotService | ||
{ | ||
public Task LogError(Exception ex, CancellationToken cancellationToken = default); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/BookStore.Application/useCases/Extensions/TelegramBot/WriteToTelegramBotService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Telegram.Bot; | ||
|
||
namespace BookStore.Application.useCases.Extensions.TelegramBot | ||
{ | ||
|
||
public class WriteToTelegramBotService : IWriteToTelegramBotService | ||
{ | ||
private readonly long _groupId = -1002007183401; | ||
private readonly TelegramBotClient _botClient; | ||
|
||
public WriteToTelegramBotService(TelegramBotClient botClient) | ||
{ | ||
_botClient = botClient; | ||
} | ||
|
||
public async Task LogError(Exception ex, CancellationToken cancellationToken) | ||
{ | ||
string errorMessage = $"An error occurred:\n\n{ex.Message}\n\nStack Trace:\n{ex.StackTrace}"; | ||
await _botClient.SendTextMessageAsync(chatId: _groupId, text: ex.ToString(), cancellationToken: cancellationToken); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.