Compare commits

...

20 Commits

Author SHA1 Message Date
7c22b4b9a7 Merge pull request '#7' (#28) from dev into main
Reviewed-on: #28
2025-07-25 18:57:13 +02:00
9a7f178023 Merge pull request '7' (#27) from 7 into dev
All checks were successful
Publish JOBot on dev / Build and deploy (push) Successful in 25s
Reviewed-on: #27
2025-07-25 18:45:27 +02:00
156ce579d4 Merge remote-tracking branch 'origin/7' into 7 2025-07-25 19:44:57 +03:00
0c6b8705ee fix: fixed production compose file 2025-07-25 19:44:51 +03:00
3085d5e778 Merge pull request '7' (#26) from 7 into dev
Some checks failed
Publish JOBot on dev / Build and deploy (push) Failing after 20s
Reviewed-on: #26
2025-07-25 18:43:50 +02:00
8b1ead20c9 Merge branch 'dev' into 7 2025-07-25 18:43:45 +02:00
176cf194cd fix: fixed migration by lazy load of rabbitmq 2025-07-25 19:43:14 +03:00
17cec6dd64 fix: removed async in lock tasks 2025-07-25 19:04:38 +03:00
0f1c7581b8 Merge pull request '7' (#25) from 7 into dev
Some checks failed
Publish JOBot on dev / Build and deploy (push) Failing after 26s
Reviewed-on: #25
2025-07-25 17:38:02 +02:00
970526d84e feat: created auth hook on TClient 2025-07-25 18:35:59 +03:00
f115760713 feat: added auth hook using RabbitMQ on client for login continue 2025-07-25 17:12:10 +03:00
d2280cdc5b chore: cleanup 2025-07-25 16:39:22 +03:00
b15a77557e chore: cleanup 2025-07-25 16:37:42 +03:00
7ceb8f656e chore: added doc for attribute 2025-07-25 16:31:57 +03:00
8c9973e55d feat: added RabbitMQ queue from back-end to hook auth for client 2025-07-25 16:27:27 +03:00
06367a3ccd chore: cleanup 2025-07-24 20:40:58 +03:00
1f3d4525d8 chore: added RabbitMQ package to docker and csproj 2025-07-24 20:40:23 +03:00
8018cb6496 feat: added boilerplate cap for next stage of user prepare 2025-07-24 20:19:38 +03:00
003d2201e5 chore: .gitignore updated 2025-07-18 17:25:33 +03:00
8de65abea5 fix: fix of run on development env 2025-07-18 17:21:45 +03:00
37 changed files with 535 additions and 280 deletions

View File

@ -20,6 +20,5 @@ jobs:
docker compose -f compose.dev.yml up -d postgres
cd /home/dockeruser/jobot-stack/JOBot.Backend
dotnet ef database update -- --environment Development
docker compose up --build -d
dotnet ef database update --connection "Host=localhost;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
docker compose up --build -d

1
.gitignore vendored
View File

@ -404,6 +404,7 @@ FodyWeavers.xsd
.docker
# Secrets
JOBot.Backend/appsettings.Development.json
JOBot.TClient/appsettings.json
/.idea/.idea.JOBot/Docker/compose.generated.override.yml
/.idea/.idea.JOBot/Docker/compose.dev.generated.override.yml

View File

@ -8,14 +8,13 @@ namespace JOBot.Backend.Controllers;
public class HeadHunterHookController(HeadHunterService hhService)
: ControllerBase
{
[HttpGet]
public async Task<IActionResult> Get(int userId, string? error, string code)
{
var res = await hhService.AuthUser(userId, code, error);
return res switch
{
HeadHunterService.Status.Success => Ok("Авторизация завершена успешно. Вернитесь в Telegram для продолжения."),
HeadHunterService.Status.Success => Ok("Авторизация завершена успешно. Вернитесь в Telegram для продолжения."),
HeadHunterService.Status.UserNotFoundError => NotFound("Пользователь не найден."),
_ => BadRequest("Авторизация завершена с ошибкой. Вернитесь в Telegram для продолжения.") //TODO: Add resource
};

View File

@ -1,14 +1,14 @@
namespace JOBot.Backend.DAL.Context;
using Models;
using JOBot.Backend.DAL.Models;
using Microsoft.EntityFrameworkCore;
namespace JOBot.Backend.DAL.Context;
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
public DbSet<User> Users { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>()

View File

@ -9,12 +9,12 @@ public class User
{
public Guid Id { get; set; }
[Key]
public required long UserId { get; set; }
[MaxLength(255)]
public string? Username { get; set; }
[Key] public required long UserId { get; set; }
[MaxLength(255)] public string? Username { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
[MaxLength(255)] public string? AccessToken { get; set; } = null;
[MaxLength(255)] public string? RefreshToken { get; set; } = null;

View File

@ -3,12 +3,12 @@ using System.Text.Json.Serialization;
namespace JOBot.Backend.DTOs.HeadHunterHook;
public record HeadHunterTokenResponseDto(
[property:JsonPropertyName("access_token")]
[property: JsonPropertyName("access_token")]
string AccessToken,
[property:JsonPropertyName("expires_in")]
[property: JsonPropertyName("expires_in")]
int ExpiresIn,
[property:JsonPropertyName("refresh_token")]
[property: JsonPropertyName("refresh_token")]
string RefreshToken,
[property:JsonPropertyName("token_type")]
[property: JsonPropertyName("token_type")]
string TokenType
);
);

View File

@ -1,33 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.30.2" />
<PackageReference Include="Grpc.AspNetCore" Version="2.71.0" />
<PackageReference Include="Grpc.AspNetCore.Server.Reflection" Version="2.71.0" />
<PackageReference Include="Grpc.Tools" Version="2.71.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.30.2"/>
<PackageReference Include="Grpc.AspNetCore" Version="2.71.0"/>
<PackageReference Include="Grpc.AspNetCore.Server.Reflection" Version="2.71.0"/>
<PackageReference Include="Grpc.Tools" Version="2.71.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4"/>
<PackageReference Include="RabbitMQ.Client" Version="7.1.2"/>
</ItemGroup>
<ItemGroup>
<Protobuf Include="..\Proto\*" GrpcServices="Server"></Protobuf>
</ItemGroup>
<ItemGroup>
<Protobuf Include="..\Proto\*" GrpcServices="Server"></Protobuf>
</ItemGroup>
<ItemGroup>
<Folder Include="Data\Migrations\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\Migrations\"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JOBot.Infrastructure\JOBot.Infrastructure.csproj" />
</ItemGroup>
</Project>

View File

@ -1,79 +1,103 @@
using System.Text;
using System.Text.Json;
using System.Web;
using JOBot.Backend.DAL.Context;
using JOBot.Backend.DTOs.HeadHunterHook;
using JOBot.Backend.Infrastructure.Config;
using JOBot.Infrastructure.Config;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using RabbitMQ.Client;
namespace JOBot.Backend.Services;
public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadHunterConfig> config, AppDbContext dbContext)
public class HeadHunterService(
IChannel channel,
ILogger<HeadHunterService> logger,
IOptions<HeadHunterConfig> config,
IWebHostEnvironment env,
AppDbContext dbContext)
{
public enum Status
{
UserAuthRejectedError,
HeadHunterAuthRejectedError,
UserNotFoundError,
HeadHunterResponseDeserializationFailedError,
Success
}
private readonly HeadHunterConfig _config = config.Value;
/// <summary>
/// Generate HeadHunter oauth authorization link
/// Generate HeadHunter oauth authorization link
/// </summary>
/// <param name="userId">Telegram UserId</param>
/// <returns>Link for auth</returns>
public string GenerateAuthLink(long userId)
{
return string.Format(_config.Links.AuthLink, [_config.ClientId, GetRedirectUrl(userId)]);
}
public async Task<Status> AuthUser(int userId, string authorizationCode, string? error)
public async Task<Status> AuthUser(int userId, string authorizationCode, string? error) //TODO: Разбить этот метод
{
logger.LogInformation($"Authorization for user {userId} in process...");
if (!string.IsNullOrEmpty(error))
{
logger.LogWarning($"User {userId} auth completed with error {error}");
return Status.UserAuthRejectedError;
}
using var client = new HttpClient();
var form = new Dictionary<string, string>
HeadHunterTokenResponseDto? responseDto;
if (!env.IsDevelopment()) //Production server
{
{ "client_id", _config.ClientId },
{ "client_secret", _config.Secret },
{ "code", authorizationCode },
{ "grant_type", "authorization_code" },
{ "redirect_uri", GetRedirectUrl(userId) }
};
client.BaseAddress = new UriBuilder(_config.Links.HeadHunterApiDomain)
{
Port = -1,
Scheme = "https"
}.Uri;
client.DefaultRequestHeaders.UserAgent.ParseAdd("Jobot BackEnd Service");
using var res = await client.SendAsync(
new HttpRequestMessage(
HttpMethod.Post,
_config.Links.HeadHunterTokenRoute)
using var client = new HttpClient();
var form = new Dictionary<string, string>
{
Content = new FormUrlEncodedContent(form)
});
{ "client_id", _config.ClientId },
{ "client_secret", _config.Secret },
{ "code", authorizationCode },
{ "grant_type", "authorization_code" },
{ "redirect_uri", GetRedirectUrl(userId) }
};
client.BaseAddress = new UriBuilder(_config.Links.HeadHunterApiDomain)
{
Port = -1,
Scheme = "https"
}.Uri;
client.DefaultRequestHeaders.UserAgent.ParseAdd("Jobot BackEnd Service");
if (!res.IsSuccessStatusCode)
{
logger.LogWarning($"Response of HttpRequest {_config.Links.HeadHunterApiDomain}" +
$"{_config.Links.HeadHunterTokenRoute} has unsuccessful status code {res.StatusCode}");
logger.LogWarning($"{res.Content.ReadAsStringAsync().Result}");
return Status.HeadHunterAuthRejectedError;
}
var responseDto = JsonSerializer.Deserialize<HeadHunterTokenResponseDto>(await res.Content.ReadAsStringAsync());
using var res = await client.SendAsync(
new HttpRequestMessage(
HttpMethod.Post,
_config.Links.HeadHunterTokenRoute)
{
Content = new FormUrlEncodedContent(form)
});
if (responseDto == null)
{
logger.LogWarning($"User {userId} auth completed with error " +
$"{nameof(Status.HeadHunterResponseDeserializationFailedError)}");
return Status.HeadHunterResponseDeserializationFailedError;
if (!res.IsSuccessStatusCode)
{
logger.LogWarning($"Response of HttpRequest {_config.Links.HeadHunterApiDomain}" +
$"{_config.Links.HeadHunterTokenRoute} has unsuccessful status code {res.StatusCode}");
logger.LogWarning($"{res.Content.ReadAsStringAsync().Result}");
return Status.HeadHunterAuthRejectedError;
}
responseDto =
JsonSerializer.Deserialize<HeadHunterTokenResponseDto>(await res.Content.ReadAsStringAsync());
if (responseDto == null)
{
logger.LogWarning($"User {userId} auth completed with error " +
$"{nameof(Status.HeadHunterResponseDeserializationFailedError)}");
return Status.HeadHunterResponseDeserializationFailedError;
}
}
else
{
responseDto = new HeadHunterTokenResponseDto("testtoken", 0, "testtoken", "--");
}
var user = await dbContext.Users.FirstOrDefaultAsync(x => x.UserId == userId);
if (user == null)
@ -81,13 +105,21 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
logger.LogWarning($"User {userId} search completed with error {nameof(Status.UserNotFoundError)}");
return Status.UserNotFoundError;
}
user.AccessToken = responseDto.AccessToken;
user.RefreshToken = responseDto.RefreshToken;
await dbContext.SaveChangesAsync();
logger.LogInformation($"User {userId} auth completed!");
await channel.BasicPublishAsync(
string.Empty,
RabbitQueues.AuthQueue,
Encoding.UTF8.GetBytes(userId.ToString()));
logger.LogInformation("RabbitMQ event was created");
return Status.Success;
}
@ -101,13 +133,4 @@ public class HeadHunterService(ILogger<HeadHunterService> logger, IOptions<HeadH
Query = $"?userId={userId}"
}.ToString();
}
public enum Status
{
UserAuthRejectedError,
HeadHunterAuthRejectedError,
UserNotFoundError,
HeadHunterResponseDeserializationFailedError,
Success
}
}

View File

@ -1,4 +1,3 @@
using Google.Protobuf.WellKnownTypes;
using Grpc.Core;
using JOBot.Backend.DAL.Context;
using JOBot.Backend.DAL.Models;
@ -11,7 +10,7 @@ namespace JOBot.Backend.Services.gRPC;
public class UserService(AppDbContext dbContext, HeadHunterService hhService) : Proto.User.UserBase
{
/// <summary>
/// Create user
/// Create user
/// </summary>
/// <param name="request"></param>
/// <param name="_"></param>
@ -32,7 +31,7 @@ public class UserService(AppDbContext dbContext, HeadHunterService hhService) :
}
/// <summary>
/// Get user for client
/// Get user for client
/// </summary>
/// <param name="request"></param>
/// <param name="_"></param>
@ -46,7 +45,7 @@ public class UserService(AppDbContext dbContext, HeadHunterService hhService) :
}
/// <summary>
/// Accept EULA for user
/// Accept EULA for user
/// </summary>
/// <param name="request"></param>
/// <param name="_"></param>
@ -64,7 +63,7 @@ public class UserService(AppDbContext dbContext, HeadHunterService hhService) :
}
public override Task<GetHeadHunterAuthHookResponse> GetHeadHunterAuthHook(
GetHeadHunterAuthHookRequest request,
GetHeadHunterAuthHookRequest request,
ServerCallContext context)
{
return Task.Run(() => new GetHeadHunterAuthHookResponse
@ -74,7 +73,7 @@ public class UserService(AppDbContext dbContext, HeadHunterService hhService) :
}
/// <summary>
/// Throw RPCException if user not found
/// Throw RPCException if user not found
/// </summary>
/// <param name="user"></param>
/// <exception cref="RpcException"></exception>

View File

@ -2,7 +2,9 @@ using JOBot.Backend.DAL.Context;
using JOBot.Backend.Infrastructure.Config;
using JOBot.Backend.Services;
using JOBot.Backend.Services.gRPC;
using JOBot.Infrastructure.Config;
using Microsoft.EntityFrameworkCore;
using RabbitMQ.Client;
namespace JOBot.Backend;
@ -12,7 +14,7 @@ public class Startup(IConfiguration configuration)
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpc();
services.AddGrpc();
services.AddGrpcReflection();
services.AddControllers();
services.AddLogging();
@ -20,6 +22,23 @@ public class Startup(IConfiguration configuration)
services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(Configuration.GetConnectionString("PostgreSQL")));
services.AddSingleton<IChannel>(x =>
{
var rabbitMqConnection = new ConnectionFactory
{
HostName = "rabbitmq"
}.CreateConnectionAsync().Result;
var channel = rabbitMqConnection.CreateChannelAsync().Result;
channel.QueueDeclareAsync(
RabbitQueues.AuthQueue,
false,
false,
false,
arguments: null).Wait();
return channel;
});
services.Configure<HeadHunterConfig>(Configuration.GetSection(HeadHunterConfig.SectionName));
services.AddScoped<HeadHunterService>();

View File

@ -1,11 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"PostgreSQL": "Host=localhost;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
}
}

View File

@ -1,35 +1,35 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"PostgreSQL": "Host=postgres;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
},
"HeadHunter": {
"Links": {
"AuthLink": "https://hh.ru/oauth/authorize?response_type=code&client_id={0}&redirect_uri={1}",
"HookDomain": "jobot.lisoveliy.su",
"HookRoute": "/auth",
"HeadHunterApiDomain": "api.hh.ru",
"HeadHunterTokenRoute": "/token"
},
"ClientId": "",
"Secret": ""
},
"Kestrel": {
"Endpoints": {
"gRPC": {
"Url": "http://*:5001",
"Protocols": "Http2"
},
"REST": {
"Url": "http://*:5000",
"Protocols": "Http1"
}
}
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"PostgreSQL": "Host=postgres;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
},
"HeadHunter": {
"Links": {
"AuthLink": "https://hh.ru/oauth/authorize?response_type=code&client_id={0}&redirect_uri={1}",
"HookDomain": "jobot.lisoveliy.su",
"HookRoute": "/auth",
"HeadHunterApiDomain": "api.hh.ru",
"HeadHunterTokenRoute": "/token"
},
"ClientId": "",
"Secret": ""
},
"Kestrel": {
"Endpoints": {
"gRPC": {
"Url": "http://*:5001",
"Protocols": "Http2"
},
"REST": {
"Url": "http://*:5000",
"Protocols": "Http1"
}
}
}
}

View File

@ -0,0 +1,6 @@
namespace JOBot.Infrastructure.Config;
public static class RabbitQueues
{
public const string AuthQueue = "auth";
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root"
xmlns="">
<xsd:element name="root" msdata:IsDataSet="true">
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
@ -13,10 +14,14 @@
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="EULAAgrement" xml:space="preserve">
<value>Соглашаюсь с условиями использования ✅</value>

View File

@ -1,9 +1,7 @@
using JOBot.Proto;
using JOBot.TClient.Infrastructure.Attributes.Authorization;
using JOBot.TClient.Services;
using JOBot.TClient.Statements;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
namespace JOBot.TClient.Commands.Buttons;

View File

@ -1,3 +1,4 @@
using JOBot.TClient.Infrastructure.Extensions;
using Telegram.Bot;
using Telegram.Bot.Types;
@ -8,7 +9,7 @@ public class InfoCommand(ITelegramBotClient bot) : ITelegramCommand
public async Task ExecuteAsync(Update update, CancellationToken ct)
{
ArgumentNullException.ThrowIfNull(update.Message?.From);
await bot.SendMessage(update.Message.From.Id, TextResource.Info, cancellationToken: ct);
await bot.SendMessageRemK(update.Message.From.Id, TextResource.Info, cancellationToken: ct);
}
}

View File

@ -1,17 +1,18 @@
using JOBot.Proto;
using Telegram.Bot;
using Telegram.Bot.Types;
namespace JOBot.TClient.Commands;
public interface IAuthorizedTelegramCommand : ITelegramCommand
{
public Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct);
/// <exception cref="UnauthorizedAccessException">Throws if you try to use ITelegramCommand.ExecuteAsync
/// instead of IAuthorizedTelegramCommand.ExecuteAsync</exception>
/// <exception cref="UnauthorizedAccessException">
/// Throws if you try to use ITelegramCommand.ExecuteAsync
/// instead of IAuthorizedTelegramCommand.ExecuteAsync
/// </exception>
Task ITelegramCommand.ExecuteAsync(Update update, CancellationToken ct)
{
throw new UnauthorizedAccessException("You do not have permission to access this command.");
}
public Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct);
}

View File

@ -5,10 +5,10 @@ using JOBot.TClient.Infrastructure.Attributes.Authorization;
using JOBot.TClient.Infrastructure.Extensions;
using JOBot.TClient.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Telegram.Bot;
using Telegram.Bot.Types;
using Microsoft.Extensions.Hosting;
namespace JOBot.TClient.Core.HostedServices;
@ -22,8 +22,8 @@ public sealed class BotBackgroundService(
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
botClient.StartReceiving(
updateHandler: HandleUpdateAsync,
errorHandler: HandleErrorAsync,
HandleUpdateAsync,
HandleErrorAsync,
cancellationToken: stoppingToken);
return Task.CompletedTask;
@ -40,7 +40,7 @@ public sealed class BotBackgroundService(
["/info"] = scope.ServiceProvider.GetRequiredService<InfoCommand>(),
//Buttons
[ButtonResource.EULAAgrement] = scope.ServiceProvider.GetRequiredService<EulaAgreementButtonCommand>(),
[ButtonResource.EULAAgrement] = scope.ServiceProvider.GetRequiredService<EulaAgreementButtonCommand>()
};
if (update.Message is { Text: { } text, From: not null })
@ -69,12 +69,15 @@ public sealed class BotBackgroundService(
await authorizedTelegramCommand.ExecuteAsync(update, user, ct);
}
else await command.ExecuteAsync(update, ct);
else
{
await command.ExecuteAsync(update, ct);
}
return;
}
await bot.SendMessage(update.Message.From.Id, TextResource.CommandNotFound, cancellationToken: ct);
await bot.SendMessageRemK(update.Message.From.Id, TextResource.CommandNotFound, cancellationToken: ct);
}
}

View File

@ -1,57 +0,0 @@
using Grpc.Core;
using Grpc.Net.Client;
using JOBot.Proto;
using JOBot.TClient.Commands.Buttons;
using JOBot.TClient.Commands.Commands;
using JOBot.TClient.Core.HostedServices;
using JOBot.TClient.Services;
using JOBot.TClient.Statements;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Telegram.Bot;
namespace JOBot.TClient;
public static class DependencyInjection
{
public static IServiceCollection ConfigureServices(this IServiceCollection services, IConfiguration config)
{
services.AddSingleton(config);
services.AddScoped<ChannelBase, GrpcChannel>(_ => GrpcChannel.ForAddress(config.GetValue<string>("BackendHost")
?? throw new MissingFieldException("Host is not defined")));
#region Commands
services.AddScoped<StartCommand>();
services.AddScoped<MenuCommand>();
services.AddScoped<InfoCommand>();
//buttons
services.AddScoped<EulaAgreementButtonCommand>();
#endregion
#region gRPC Clients
services.AddGrpcClient<User.UserClient>(o => o.Address = new Uri("http://backend:5001"));
#endregion
#region Services
services.AddSingleton<UserService>();
services.AddScoped<PrepareUserService>();
services.AddScoped<MenuService>();
#endregion
#region States
services.AddScoped<PrepareUserState>();
#endregion
// Bot service
services.AddHostedService<BotBackgroundService>();
services.AddSingleton<ITelegramBotClient>(_ =>
new TelegramBotClient(config.GetValue<string>("TelegramToken")
?? throw new MissingFieldException("TelegramToken is not set")));
services.AddLogging(builder => builder.AddConsole());
return services;
}
}

View File

@ -1,4 +1,7 @@
namespace JOBot.TClient.Infrastructure.Attributes.Authorization;
/// <summary>
/// Атрибут допуска к команде пользователя не завершившего стадию PrepareUser
/// </summary>
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public class AcceptNotPreparedAttribute : Attribute;

View File

@ -1,17 +1,18 @@
using JOBot.TClient.Infrastructure.Extensions;
using Telegram.Bot;
using Telegram.Bot.Types;
namespace JOBot.TClient.Infrastructure.Exceptions;
/// <summary>
/// Exception for fallback
/// WARNING: Don't create new exception without throwing it
/// Exception for fallback
/// WARNING: Don't create new exception without throwing it
/// </summary>
public class FallbackException : Exception
{
public FallbackException(string message, Message botMessage, ITelegramBotClient botClient) : base(message)
{
botClient.SendMessage(chatId: botMessage.Chat.Id,
botClient.SendMessageRemK(botMessage.Chat.Id,
TextResource.FallbackMessage);
}
}

View File

@ -4,6 +4,9 @@ namespace JOBot.TClient.Infrastructure.Extensions;
public static class GRpcModelsExtensions
{
public static bool IsPrepared(this GetUserResponse user) => user is { Eula: true, IsLogged: true } &&
!string.IsNullOrEmpty(user.CVUrl);
public static bool IsPrepared(this GetUserResponse user)
{
return user is { Eula: true, IsLogged: true } &&
!string.IsNullOrEmpty(user.CVUrl);
}
}

View File

@ -0,0 +1,52 @@
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups;
namespace JOBot.TClient.Infrastructure.Extensions;
public static class TelegramBotClientExtensions
{
/// <summary>
/// Extension method for auto-remove of reply keyboard if is null
/// </summary>
/// <param name="bot"></param>
/// <param name="chatId"></param>
/// <param name="text"></param>
/// <param name="parseMode"></param>
/// <param name="replyParameters"></param>
/// <param name="replyMarkup"></param>
/// <param name="linkPreviewOptions"></param>
/// <param name="messageThreadId"></param>
/// <param name="entities"></param>
/// <param name="disableNotification"></param>
/// <param name="protectContent"></param>
/// <param name="messageEffectId"></param>
/// <param name="businessConnectionId"></param>
/// <param name="allowPaidBroadcast"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static Task<Message> SendMessageRemK(
this ITelegramBotClient bot,
ChatId chatId,
string text,
ParseMode parseMode = default,
ReplyParameters? replyParameters = null,
ReplyMarkup? replyMarkup = null,
LinkPreviewOptions? linkPreviewOptions = null,
int? messageThreadId = null,
IEnumerable<MessageEntity>? entities = null,
bool disableNotification = false,
bool protectContent = false,
string? messageEffectId = null,
string? businessConnectionId = null,
bool allowPaidBroadcast = false,
CancellationToken cancellationToken = default)
{
replyMarkup ??= new ReplyKeyboardRemove();
return bot.SendMessage(chatId, text, parseMode, replyParameters, replyMarkup, linkPreviewOptions, messageThreadId,
entities, disableNotification, protectContent, messageEffectId, businessConnectionId, allowPaidBroadcast,
cancellationToken);
}
}

View File

@ -20,6 +20,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.4"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4"/>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.4"/>
<PackageReference Include="RabbitMQ.Client" Version="7.1.2"/>
<PackageReference Include="Telegram.Bot" Version="22.5.1"/>
</ItemGroup>
@ -58,9 +59,13 @@
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JOBot.Infrastructure\JOBot.Infrastructure.csproj" />
</ItemGroup>
</Project>

View File

@ -6,7 +6,6 @@ var host = Host.CreateDefaultBuilder(args)
{
// Настройка DI
services.ConfigureServices(context.Configuration);
})
.Build();

View File

@ -0,0 +1,24 @@
using System.Text;
using JOBot.Infrastructure.Config;
using JOBot.TClient.Services;
using Microsoft.Extensions.Hosting;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
namespace JOBot.TClient.Queues;
public class AuthQueue(IChannel channel, PrepareUserService prepareUserService) : BackgroundService
{
private async Task OnDataReceivedAsync(object sender, BasicDeliverEventArgs eventArgs)
{
await prepareUserService.AuthHookReceived(Convert.ToInt64(Encoding.UTF8.GetString(eventArgs.Body.ToArray())));
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var consumer = new AsyncEventingBasicConsumer(channel);
consumer.ReceivedAsync += OnDataReceivedAsync;
await channel.BasicConsumeAsync(RabbitQueues.AuthQueue, autoAck: true, consumer: consumer, cancellationToken: stoppingToken);
}
}

View File

@ -1,6 +1,6 @@
using JOBot.TClient.Infrastructure.Extensions;
using Telegram.Bot;
using Telegram.Bot.Types;
using User = JOBot.Proto.User;
namespace JOBot.TClient.Services;
@ -9,7 +9,7 @@ public class MenuService(ITelegramBotClient bot)
public async Task RenderMenu(Update update, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(update.Message?.From);
await bot.SendMessage(update.Message.From.Id,"PrepareUser stage is done.", cancellationToken: ct);
await bot.SendMessageRemK(update.Message.From.Id, "PrepareUser stage is done.", cancellationToken: ct);
}
}

View File

@ -1,5 +1,6 @@
using JOBot.Proto;
using JOBot.TClient.Infrastructure.Exceptions;
using JOBot.TClient.Infrastructure.Extensions;
using Telegram.Bot;
using Telegram.Bot.Types;
using User = JOBot.Proto.User;
@ -12,13 +13,13 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
private readonly User.UserClient _userClient = userClient;
/// <summary>
/// Get or register user on system
/// Get or register user on system
/// </summary>
/// <param name="update">Telegram Update object</param>
/// <param name="ct">Cancellation Token</param>
/// <returns>RPC User Response</returns>
/// <exception cref="FallbackException">If something in server logic went wrong</exception>
/// <exception cref="ArgumentNullException">If update.Message is null</exception>
/// <exception cref="ArgumentNullException">update.Message is null</exception>
public async Task<GetUserResponse> RegisterUser(Update update, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(update.Message?.From);
@ -26,21 +27,21 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
var result = await _userClient.RegisterAsync(new RegisterRequest
{
UserId = update.Message.From.Id,
Username = update.Message.From.Username,
Username = update.Message.From.Username
});
if (!result.Success)
{
await _bot.SendMessage(chatId: update.Message.Chat.Id,
await _bot.SendMessageRemK(update.Message.Chat.Id,
TextResource.FallbackMessage,
cancellationToken: ct);
throw new FallbackException(TextResource.FallbackMessage, update.Message, _bot);
}
var user = await _userClient.GetUserAsync(new GetUserRequest()
var user = await _userClient.GetUserAsync(new GetUserRequest
{
UserId = update.Message.From.Id,
UserId = update.Message.From.Id
});
if (user == null)
@ -50,23 +51,23 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
}
/// <summary>
/// Get Eula Agreement from user
/// Get Eula Agreement from user
/// </summary>
/// <param name="update">Telegram Update object</param>
/// <param name="ct">Cancellation Token</param>
/// <exception cref="ArgumentNullException">If update.Message is null</exception>
/// <exception cref="ArgumentNullException">update.Message is null</exception>
public async Task AskForEulaAgreement(Update update, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(update.Message?.From);
await _bot.SendMessage(
await _bot.SendMessageRemK(
update.Message.From.Id,
TextResource.EULA,
replyMarkup: new[] { ButtonResource.EULAAgrement }, cancellationToken: ct);
}
/// <summary>
/// Accept EULA for user
/// Accept EULA for user
/// </summary>
/// <param name="update">Telegram update object</param>
/// <param name="ct">Cancellation Token</param>
@ -74,10 +75,10 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
public async Task AcceptEula(Update update, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(update.Message?.From);
var result = await _userClient.AcceptEulaAsync(new()
var result = await _userClient.AcceptEulaAsync(new AcceptEulaRequest
{
EulaAccepted = true,
UserId = update.Message.From.Id,
UserId = update.Message.From.Id
});
if (!result.Success)
@ -87,15 +88,34 @@ public class PrepareUserService(ITelegramBotClient bot, User.UserClient userClie
public async Task Auth(Update update, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(update.Message?.From);
var url = await _userClient.GetHeadHunterAuthHookAsync(new GetHeadHunterAuthHookRequest()
var url = await _userClient.GetHeadHunterAuthHookAsync(new GetHeadHunterAuthHookRequest
{
UserId = update.Message.From.Id
});
await _bot.SendMessage(
update.Message.From.Id,
string.Format(TextResource.AskForAuth, [url.RegistrationUrl]),
await _bot.SendMessageRemK(
update.Message.From.Id,
string.Format(TextResource.AskForAuth, [url.RegistrationUrl]),
cancellationToken: ct);
}
public async Task AuthHookReceived(long userId, CancellationToken ct = default)
{
await _bot.SendMessageRemK(userId, "✅ Авторизация завершена успешно!", cancellationToken: ct);
await SelectCv(userId, ct);
}
public async Task SelectCv(Update update, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(update.Message?.From);
await SelectCv(update.Message.From.Id, ct);
}
public async Task SelectCv(long userId, CancellationToken ct = default)
{
await _bot.SendMessageRemK(userId, "Давайте выберем одно из доступных резюме:",
cancellationToken: ct); //TODO: https://git.lisoveliy.su/Lisoveliy/JOBot/issues/9
}
}

View File

@ -10,7 +10,7 @@ namespace JOBot.TClient.Services;
public class UserService(ITelegramBotClient bot, User.UserClient userClient)
{
/// <summary>
/// Get user
/// Get user
/// </summary>
/// <param name="update">Telegram Update object</param>
/// <param name="ct">Cancellation Token</param>
@ -26,7 +26,7 @@ public class UserService(ITelegramBotClient bot, User.UserClient userClient)
{
user = await userClient.GetUserAsync(new GetUserRequest() //Получаем пользователя
{
UserId = update.Message.From.Id,
UserId = update.Message.From.Id
});
}
catch (RpcException e) //Пользователь не найден?
@ -36,6 +36,7 @@ public class UserService(ITelegramBotClient bot, User.UserClient userClient)
return null;
}
return user;
}
}

87
JOBot.TClient/Startup.cs Normal file
View File

@ -0,0 +1,87 @@
using Grpc.Core;
using Grpc.Net.Client;
using JOBot.Infrastructure.Config;
using JOBot.Proto;
using JOBot.TClient.Commands.Buttons;
using JOBot.TClient.Commands.Commands;
using JOBot.TClient.Core.HostedServices;
using JOBot.TClient.Queues;
using JOBot.TClient.Services;
using JOBot.TClient.Statements;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
using Telegram.Bot;
namespace JOBot.TClient;
public static class Startup
{
public static IServiceCollection ConfigureServices(this IServiceCollection services, IConfiguration config)
{
services.AddSingleton(config);
services.AddSingleton(_ => GrpcChannel.ForAddress(config.GetValue<string>("BackendHost")
?? throw new MissingFieldException("Host is not defined")));
#region Commands
services.AddSingleton<StartCommand>();
services.AddSingleton<MenuCommand>();
services.AddSingleton<InfoCommand>();
//buttons
services.AddSingleton<EulaAgreementButtonCommand>();
#endregion
#region gRPC Clients
services.AddGrpcClient<User.UserClient>(o => o.Address = new Uri("http://backend:5001"));
#endregion
#region Services
services.AddSingleton<UserService>();
services.AddSingleton<PrepareUserService>();
services.AddSingleton<MenuService>();
#endregion
#region States
services.AddSingleton<PrepareUserState>();
#endregion
#region RabbitMQ Clients
var factory = new ConnectionFactory { HostName = "rabbitmq" };
var connection = factory.CreateConnectionAsync().Result;
var channel = connection.CreateChannelAsync().Result;
channel.QueueDeclareAsync(
RabbitQueues.AuthQueue,
false,
false,
false,
arguments: null).Wait();
services.AddSingleton(channel);
services.AddHostedService<AuthQueue>();
#endregion
// Bot service
services.AddHostedService<BotBackgroundService>();
services.AddSingleton<ITelegramBotClient>(_ =>
new TelegramBotClient(config.GetValue<string>("TelegramToken")
?? throw new MissingFieldException("TelegramToken is not set")));
services.AddLogging(builder => builder.AddConsole());
return services;
}
}

View File

@ -1,14 +1,13 @@
using JOBot.Proto;
using JOBot.TClient.Services;
using Telegram.Bot.Types;
using User = JOBot.Proto.User;
namespace JOBot.TClient.Statements;
public class PrepareUserState(PrepareUserService prepareUserService, MenuService menuService)
{
/// <summary>
/// Try to prepare user if is not registered
/// Try to prepare user if is not registered
/// </summary>
/// <param name="update">Update telegram object</param>
/// <param name="ct">Cancellation token</param>
@ -21,24 +20,24 @@ public class PrepareUserState(PrepareUserService prepareUserService, MenuService
await prepareUserService.AskForEulaAgreement(update, ct);
return; //interrupt while eula isn't accepted
}
await OnUserEulaValidStage(user, update, ct);
}
/// <summary>
/// Signal for accepted eula
/// Signal for accepted eula
/// </summary>
/// <param name="user"></param>
/// <param name="update"></param>
/// <param name="ct"></param>
public async Task AcceptEula(GetUserResponse user, Update update, CancellationToken ct = default)
{
await prepareUserService.AcceptEula(update, ct: ct);
await prepareUserService.AcceptEula(update, ct);
await OnUserEulaValidStage(user, update, ct);
}
/// <summary>
/// Continue prepare stage
/// Check user logged
/// </summary>
/// <param name="user"></param>
/// <param name="update"></param>
@ -50,6 +49,19 @@ public class PrepareUserState(PrepareUserService prepareUserService, MenuService
await prepareUserService.Auth(update, ct);
return;
}
await OnAuthStage(user, update, ct);
}
/// <summary>
/// Check user selected CV
/// </summary>
/// <param name="user"></param>
/// <param name="update"></param>
/// <param name="ct"></param>
private async Task OnAuthStage(GetUserResponse user, Update update, CancellationToken ct = default)
{
if (string.IsNullOrEmpty(user.CVUrl)) await prepareUserService.SelectCv(update, ct);
await menuService.RenderMenu(update, ct); //boilerplate
}
}

View File

@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root"
xmlns="">
<xsd:element name="root" msdata:IsDataSet="true">
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
@ -13,10 +14,14 @@
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data name="EULA" xml:space="preserve">
<value>Продолжая, вы принимаете политику конфиденциальности и правила сервиса

View File

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.Backend", "JOBot.Back
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.TClient", "JOBot.TClient\JOBot.TClient.csproj", "{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JOBot.Infrastructure", "JOBot.Infrastructure\JOBot.Infrastructure.csproj", "{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -41,6 +43,18 @@ Global
{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}.Release|x64.Build.0 = Release|Any CPU
{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}.Release|x86.ActiveCfg = Release|Any CPU
{4526BCB1-DAD3-430C-BD7C-9C114DFE9A2A}.Release|x86.Build.0 = Release|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|x64.ActiveCfg = Debug|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|x64.Build.0 = Debug|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|x86.ActiveCfg = Debug|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Debug|x86.Build.0 = Debug|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|Any CPU.Build.0 = Release|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|x64.ActiveCfg = Release|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|x64.Build.0 = Release|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|x86.ActiveCfg = Release|Any CPU
{32006B71-E6F7-4264-A8B4-AC3A6B77CC54}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -5,7 +5,7 @@ Telegram-бот для автоматизации поиска работы че
## 🔥 Возможности
Привяжите аккаунт HeadHunter для доступа к резюме и вакансиям.
Привяжите аккаунт HeadHunter для доступа к резюме и вакансиям.
- **Отклик по предпочтениям**
@ -16,7 +16,7 @@ Telegram-бот для автоматизации поиска работы че
- **Проверка резюме**
Правка резюме, под ваши приоритеты.
- **Аналитика**
- **Аналитика**
Статистика по откликам и приглашениям.
@ -25,36 +25,42 @@ Telegram-бот для автоматизации поиска работы че
- **Backend**: .NET 8 + gRPC
- **Frontend** Telegram клиент через Telegram.Bot
- **БД**: PostgreSQL
- **Авторизация**: OAuth 2.0 (HH API), Telegram API
- **Авторизация**: OAuth 2.0 (HH API), Telegram API
- **Инфраструктура**: Docker / Docker compose
## 🚀 Запуск
### Требования
- .NET 8 SDK
- Docker (для работы с БД)
- Аккаунт разработчика на [dev.hh.ru](https://dev.hh.ru)
### 1. Настройка конфигурации
Создайте `appsettings.json` в `JOBot.TClient` на основе `appsettings.Example.json`
### 2. Запуск через Docker
```
docker-compose up -d --build
```
## 📌 Команды бота
|Команда|Описание|
|-------|--------|
|/start |Начало работы|
|/menu|Настройка откликов и резюме по предпочтениям|
|/info|Информация о боте|
| Команда | Описание |
|---------|----------------------------------------------|
| /start | Начало работы |
| /menu | Настройка откликов и резюме по предпочтениям |
| /info | Информация о боте |
📄 Лицензия
MIT License. Подробнее в файле LICENSE.
## Отказ от ответственности
Продолжая, вы принимаете [политику конфиденциальности](https://hh.ru/article/personal_data?backurl=%2F&role=applicant) и [правила сервиса](https://hh.ru/account/agreement?backurl=%2Faccount%2Fsignup%3Fbackurl%3D%252F%26role%3Dapplicant&role=applicant) hh.ru
Продолжая, вы принимаете [политику конфиденциальности](https://hh.ru/article/personal_data?backurl=%2F&role=applicant)
и [правила сервиса](https://hh.ru/account/agreement?backurl=%2Faccount%2Fsignup%3Fbackurl%3D%252F%26role%3Dapplicant&role=applicant)
hh.ru
Этот сервис никак не связан с HeadHunter™ (далее hh.ru), не выдаёт себя за hh.ru и не является hh.ru

View File

@ -1,6 +1,17 @@
version: '3.8'
services:
rabbitmq:
hostname: jobot-rabbit
image: rabbitmq:4
ports:
- "5672:5672"
- "15672:15672"
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
networks:
- jobot
postgres:
image: postgres:15
environment:
@ -19,6 +30,7 @@ services:
dockerfile: JOBot.Backend/Dockerfile
depends_on:
- postgres
- rabbitmq
ports:
- "5000:5000"
- "5001:5001"
@ -36,6 +48,7 @@ services:
networks:
jobot:
volumes:
postgres_data:
postgres_data:
rabbitmq_data:

View File

@ -1,11 +1,19 @@
version: '3.8'
services:
rabbitmq:
hostname: jobot-rabbit
image: rabbitmq:4
volumes:
- rabbitmq_data:/var/lib/rabbitmq/
networks:
- jobot
postgres:
image: postgres:15
environment:
POSTGRES_PASSWORD: LocalDbPass
POSTGRES_DB: jobot
POSTGRES_DB: jobot
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
@ -17,6 +25,7 @@ services:
dockerfile: JOBot.Backend/Dockerfile
depends_on:
- postgres
- rabbitmq
ports:
- "5000:5000"
networks:
@ -33,7 +42,8 @@ services:
networks:
jobot:
volumes:
postgres_data:
postgres_data:
rabbitmq_data: