Update dependencies

This commit is contained in:
Sergey Nazarov 2024-03-28 09:03:02 +03:00
parent 7cc69e36c2
commit 3bca09b3b9
6 changed files with 25 additions and 34 deletions

View File

@ -7,9 +7,9 @@
<InsightTelegramBotVersion>0.16.0</InsightTelegramBotVersion>
</PropertyGroup>
<ItemGroup Label="Nocr">
<PackageVersion Include="Nocr.TextMatcher.Api.Contracts" Version="0.4.13" />
<PackageVersion Include="Nocr.TextMatcher.Async.Api.Contracts" Version="0.4.13" />
<PackageVersion Include="Nocr.Users.Api.Contracts" Version="0.4.11" />
<PackageVersion Include="Nocr.TextMatcher.Api.Contracts" Version="0.4.22" />
<PackageVersion Include="Nocr.TextMatcher.Async.Api.Contracts" Version="0.4.22" />
<PackageVersion Include="Nocr.Users.Api.Contracts" Version="0.4.22" />
</ItemGroup>
<ItemGroup Label="Rebus">
<PackageVersion Include="Rebus" Version="8.2.2" />

View File

@ -4,8 +4,9 @@ using Microsoft.Extensions.Logging;
using Nocr.TelegramClient.AppServices.Users;
using Nocr.TextMatcher.Api.Contracts.TextMatches;
using Nocr.TextMatcher.Async.Api.Contracts;
using Nocr.Users.AppServices.Contracts.Users;
using Nocr.Users.Api.Contracts.Users;
using Rebus.Handlers;
using Telegram.Bot.Types.Enums;
namespace Nocr.TelegramClient.AppServices.Matches;
@ -13,45 +14,39 @@ public class TextMatchMatchedHandler : IHandleMessages<TextMatchMatched>
{
private readonly ILogger<TextMatchMatchedHandler> _logger;
private readonly IBot _bot;
private readonly ITextMatchesController _textMatchesController;
private readonly IUsersService _usersService;
public TextMatchMatchedHandler(ILogger<TextMatchMatchedHandler> logger, IBot bot,
ITextMatchesController textMatchesController, IUsersService usersService)
public TextMatchMatchedHandler(ILogger<TextMatchMatchedHandler> logger, IBot bot, IUsersService usersService)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_bot = bot ?? throw new ArgumentNullException(nameof(bot));
_textMatchesController =
textMatchesController ?? throw new ArgumentNullException(nameof(textMatchesController));
_usersService = usersService ?? throw new ArgumentNullException(nameof(usersService));
}
public async Task Handle(TextMatchMatched message)
{
var match = await _textMatchesController.GetById(message.MatchId);
if (match == null)
{
_logger.LogWarning("Match [{MatchId}] from message {MessageId} not found", message.MatchId, message.Id);
return;
}
var user = await _usersService.GetById(message.MatchUserId);
if (user == null)
{
_logger.LogWarning("User [{UserId}] of [{MatchId}] from message {MessageId} not found", message.MatchUserId, message.MatchId, message.Id);
_logger.LogWarning("User [{UserId}] of [{MatchId}] from message {MessageId} not found", message.MatchUserId,
message.MatchId, message.Id);
return;
}
var identity = user.Identities.FirstOrDefault(x => x.Type == UserIdentityType.TelegramId);
if (identity == null)
{
_logger.LogWarning("There is no identity with type '{IdentityType}' for user '{UserId}'", UserIdentityType.TelegramId, user.Id);
_logger.LogWarning("There is no identity with type '{IdentityType}' for user '{UserId}'",
UserIdentityType.TelegramId, user.Id);
return;
}
var fromUsername = string.IsNullOrWhiteSpace(message.FromUsername) ? "anonymous" : message.FromUsername;
var textMessage = new TextMessage(long.Parse(identity.Identity))
{
Text = $"[{message.PublishedDateTime:MM.dd.yyyy HH:mm:ss}] Найдено совпадение.\n @{match.ChatUsername}. Тип совпадения: '{GetTextMatchRule(match.Rule)}', шаблон: '{match.Template}'"
Text =
$"[{message.PublishedDateTime:MM.dd.yyyy HH:mm:ss}] Найдено совпадение.</br>Тип совпадения: <b>'{GetTextMatchRule((TextMatchRule)message.Rule)}'</b></br>Шаблон: <b>'{message.Template}'</b></br>{fromUsername} в @{message.ChatUsername}: <i>{message.Text}</i>",
ParseMode = ParseMode.Html
};
await _bot.SendMessageAsync(textMessage);

View File

@ -11,8 +11,8 @@
<PackageReference Include="Nocr.Users.Api.Contracts"/>
<PackageReference Include="Rebus"/>
<PackageReference Include="Rebus.ServiceProvider"/>
<PackageReference Include="Nocr.TextMatcher.Async.Api.Contracts" />
<PackageReference Include="Nocr.TextMatcher.Api.Contracts"/>
<PackageReference Include="Nocr.TextMatcher.Async.Api.Contracts"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nocr.TelegramClient.Core\Nocr.TelegramClient.Core.csproj"/>

View File

@ -1,11 +1,9 @@
using System.Resources;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Nocr.TelegramClient.AppServices.Matches;
using Nocr.TelegramClient.AppServices.Options;
using Nocr.TelegramClient.AppServices.Users;
using Nocr.TelegramClient.Core.Options;
using Nocr.TextMatcher.Api.Contracts.TextMatches;
using Nocr.Users.Api.Contracts.Users;
using Rebus.Config;

View File

@ -1,7 +1,6 @@
using Nocr.Users.Api.Contracts.Users;
using Nocr.Users.Api.Contracts.Users.Dto;
using Nocr.Users.Api.Contracts.Users.Dto.Requests;
using Nocr.Users.AppServices.Contracts.Users;
namespace Nocr.TelegramClient.AppServices.Users;

View File

@ -1,4 +1,3 @@
using System.Data;
using Insight.TelegramBot.Handling.Infrastructure;
using Insight.TelegramBot.Hosting.DependencyInjection.Infrastructure;
using Insight.TelegramBot.Hosting.Polling.ExceptionHandlers;