Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

## [2.0.0] - 16-10-2023 #3

Merged
merged 15 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
id: meta
uses: docker/[email protected]
with:
images: ${{ secrets.DOCKER_USER }}/animemanga-notifyservice:1.1.0
images: ${{ secrets.DOCKER_USER }}/animemanga-notifyservice:2.0.0

- name: Build the Docker image Notify Service
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: true
tags: ${{ secrets.DOCKER_USER }}/animemanga-notifyservice:1.1.0, ${{ secrets.DOCKER_USER }}/animemanga-notifyservice:latest
tags: ${{ secrets.DOCKER_USER }}/animemanga-notifyservice:2.0.0, ${{ secrets.DOCKER_USER }}/animemanga-notifyservice:latest
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src

COPY ["src/Cesxhin.AnimeManga.NotifyService/", "./Cesxhin.AnimeManga.NotifyService/"]
COPY ["src/references/Cesxhin.AnimeManga.Application/", "./references/Cesxhin.AnimeManga.Application/"]
COPY ["src/Cesxhin.AnimeManga.Application/", "./Cesxhin.AnimeManga.Application/"]
COPY ["src/references/Cesxhin.AnimeManga.Modules/", "./references/Cesxhin.AnimeManga.Modules/"]
COPY ["src/references/Cesxhin.AnimeManga.Domain/", "./references/Cesxhin.AnimeManga.Domain/"]

RUN dotnet restore "./Cesxhin.AnimeManga.NotifyService/Cesxhin.AnimeManga.NotifyService.csproj"
Expand Down
3 changes: 2 additions & 1 deletion DockerfileArm32v7
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim-arm32v7 AS build
WORKDIR /src

COPY ["src/Cesxhin.AnimeManga.NotifyService/", "./Cesxhin.AnimeManga.NotifyService/"]
COPY ["src/references/Cesxhin.AnimeManga.Application/", "./references/Cesxhin.AnimeManga.Application/"]
COPY ["src/Cesxhin.AnimeManga.Application/", "./Cesxhin.AnimeManga.Application/"]
COPY ["src/references/Cesxhin.AnimeManga.Modules/", "./references/Cesxhin.AnimeManga.Modules/"]
COPY ["src/references/Cesxhin.AnimeManga.Domain/", "./references/Cesxhin.AnimeManga.Domain/"]

RUN dotnet restore "./Cesxhin.AnimeManga.NotifyService/Cesxhin.AnimeManga.NotifyService.csproj"
Expand Down
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ example:
USERNAME_RABBIT: "guest" #guest [default]
PASSWORD_RABBIT: "guest" #guest [default]
ADDRESS_RABBIT: "localhost" #localhost [default]

#--- API ---
ADDRESS_API: "localhost" #localhost [default]
PORT_API: "33333" #5000 [default]
PROTOCOL_API: "http" or "https" #http [default]

#---Webhook---
WEBHOOK_DISCORD: "url" [require]
#--- Webhook ---
WEBHOOK_DISCORD_BOOK: "url" [require]
WEBHOOK_DISCORD_BOOK_REQUEST: "url" [require]
WEBHOOK_DISCORD_VIDEO: "url" [require]
WEBHOOK_DISCORD_VIDEO_REQUEST: "url" [require]

#--- Bot Telegram ---
TOKEN_BOT: "token" [require]
CHAT_ID: "@channelusername" [require]
CHAT_ID_REQUEST: "@channelusername" [require]

#---logger---
#--- logger ---
LOG_LEVEL: "Debug|Info|Error" #Info [default]
WEBHOOK_DISCORD_DEBUG: "url" [not require]

#--- General ---
SELECT_SERVICE: "Discord|Telegram|Any"
```
4 changes: 4 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Released]
## [2.0.0] - 16-10-2023
### Added
- Support also Telegram

## [1.1.0] - 28-05-2023
### Changed
- Update lib
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BCrypt.Net-Core" Version="1.6.0" />
<PackageReference Include="Discord.Net.Webhook" Version="3.10.0" />
<PackageReference Include="FFMpegCore" Version="5.1.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="m3uParser.NET" Version="1.0.17" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.0.14" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="MongoDB.Bson" Version="2.19.1" />
<PackageReference Include="NLog" Version="5.1.3" />
<PackageReference Include="Quartz" Version="3.4.0" />
<PackageReference Include="Telegram.Bot" Version="19.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\references\Cesxhin.AnimeManga.Domain\Cesxhin.AnimeManga.Domain.csproj" />
<ProjectReference Include="..\references\Cesxhin.AnimeManga.Modules\Cesxhin.AnimeManga.Modules.csproj" />
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions src/Cesxhin.AnimeManga.Application/Consumers/NotifyBookConsumer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Cesxhin.AnimeManga.Application.Notify;
using Cesxhin.AnimeManga.Modules.NlogManager;
using Cesxhin.AnimeManga.Domain.DTO;
using Discord.Webhook;
using MassTransit;
using NLog;
using System;
using System.Threading.Tasks;

namespace Cesxhin.AnimeManga.Application.Consumers
{
public class NotifyBookConsumer : IConsumer<NotifyMangaDTO>
{
//nlog
private readonly NLogConsole _logger = new(LogManager.GetCurrentClassLogger());

//webhook discord
private readonly string _webhookDiscord = Environment.GetEnvironmentVariable("WEBHOOK_DISCORD_BOOK");

public Task Consume(ConsumeContext<NotifyMangaDTO> context)
{
DiscordWebhookClient discord = new(_webhookDiscord);
var managementNotify = new NotifyDiscord();

var notify = context.Message;
_logger.Info($"Recive this message: {notify.Message}");

managementNotify.SendNotify(discord, GenericNotify.NotifyMangaDTOToGenericNotify(notify), null);

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Cesxhin.AnimeManga.Application.Notify;
using Cesxhin.AnimeManga.Modules.NlogManager;
using Cesxhin.AnimeManga.Domain.DTO;
using MassTransit;
using NLog;
using System;
using System.Threading.Tasks;
using Telegram.Bot;

namespace Cesxhin.AnimeManga.Application.Consumers
{
public class NotifyBookTelegramConsumer : IConsumer<NotifyMangaDTO>
{
//nlog
private readonly NLogConsole _logger = new(LogManager.GetCurrentClassLogger());

//settings for bot telegram
private readonly string tokenBot = Environment.GetEnvironmentVariable("TOKEN_BOT");
private readonly string chat_id = Environment.GetEnvironmentVariable("CHAT_ID");

public Task Consume(ConsumeContext<NotifyMangaDTO> context)
{
var botTelegram = new TelegramBotClient(tokenBot);
var managementNotify = new NotifyTelegramChannel();

var notify = context.Message;
_logger.Info($"Recive this message: {context.MessageId}");

managementNotify.SendNotify(botTelegram, GenericNotify.NotifyMangaDTOToGenericNotify(notify), chat_id);

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Cesxhin.AnimeManga.Application.Notify;
using Cesxhin.AnimeManga.Modules.NlogManager;
using Cesxhin.AnimeManga.Domain.DTO;
using Discord.Webhook;
using MassTransit;
using NLog;
using System;
using System.Threading.Tasks;

namespace Cesxhin.AnimeManga.Application.Consumers
{
public class NotifyRequestBookConsumer : IConsumer<NotifyRequestMangaDTO>
{
//nlog
private readonly NLogConsole _logger = new(LogManager.GetCurrentClassLogger());

//webhook discord
private readonly string _webhookDiscord = Environment.GetEnvironmentVariable("WEBHOOK_DISCORD_BOOK_REQUEST");

public Task Consume(ConsumeContext<NotifyRequestMangaDTO> context)
{
DiscordWebhookClient discord = new(_webhookDiscord);
var managementNotify = new NotifyDiscord();

var notify = context.Message;
_logger.Info($"Recive this message: {notify.Message}");

managementNotify.SendNotify(discord, GenericNotify.NotifyRequestMangaDTOToGenericNotify(notify), null);

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Cesxhin.AnimeManga.Application.Notify;
using Cesxhin.AnimeManga.Modules.NlogManager;
using Cesxhin.AnimeManga.Domain.DTO;
using MassTransit;
using NLog;
using System;
using System.Threading.Tasks;
using Telegram.Bot;

namespace Cesxhin.AnimeManga.Application.Consumers
{
public class NotifyRequestBookTelegramConsumer : IConsumer<NotifyRequestMangaDTO>
{
//nlog
private readonly NLogConsole _logger = new(LogManager.GetCurrentClassLogger());

//settings for bot telegram
private readonly string tokenBot = Environment.GetEnvironmentVariable("TOKEN_BOT");
private readonly string chat_id = Environment.GetEnvironmentVariable("CHAT_ID_REQUEST");

public Task Consume(ConsumeContext<NotifyRequestMangaDTO> context)
{
var botTelegram = new TelegramBotClient(tokenBot);
var managementNotify = new NotifyTelegramChannel();

var notify = context.Message;
_logger.Info($"Recive this message: {context.MessageId}");

managementNotify.SendNotify(botTelegram, GenericNotify.NotifyRequestMangaDTOToGenericNotify(notify), chat_id);

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Cesxhin.AnimeManga.Application.Notify;
using Cesxhin.AnimeManga.Modules.NlogManager;
using Cesxhin.AnimeManga.Domain.DTO;
using Discord.Webhook;
using MassTransit;
using NLog;
using System;
using System.Threading.Tasks;

namespace Cesxhin.AnimeManga.Application.Consumers
{
public class NotifyRequestVideoConsumer : IConsumer<NotifyRequestAnimeDTO>
{
//nlog
private readonly NLogConsole _logger = new(LogManager.GetCurrentClassLogger());

//webhook discord
private readonly string _webhookDiscord = Environment.GetEnvironmentVariable("WEBHOOK_DISCORD_VIDEO_REQUEST");

public Task Consume(ConsumeContext<NotifyRequestAnimeDTO> context)
{
DiscordWebhookClient discord = new(_webhookDiscord);
var managementNotify = new NotifyDiscord();

var notify = context.Message;
_logger.Info($"Recive this message: {notify.Message}");

managementNotify.SendNotify(discord, GenericNotify.NotifyRequestAnimeDTOToGenericNotify(notify), null);

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Cesxhin.AnimeManga.Application.Notify;
using Cesxhin.AnimeManga.Modules.NlogManager;
using Cesxhin.AnimeManga.Domain.DTO;
using MassTransit;
using NLog;
using System;
using System.Threading.Tasks;
using Telegram.Bot;

namespace Cesxhin.AnimeManga.Application.Consumers
{
public class NotifyRequestVideoTelegramConsumer : IConsumer<NotifyRequestAnimeDTO>
{
//nlog
private readonly NLogConsole _logger = new(LogManager.GetCurrentClassLogger());

//settings for bot telegram
private readonly string tokenBot = Environment.GetEnvironmentVariable("TOKEN_BOT");
private readonly string chat_id = Environment.GetEnvironmentVariable("CHAT_ID_REQUEST");

public Task Consume(ConsumeContext<NotifyRequestAnimeDTO> context)
{
var botTelegram = new TelegramBotClient(tokenBot);
var managementNotify = new NotifyTelegramChannel();

var notify = context.Message;
_logger.Info($"Recive this message: {context.MessageId}");

managementNotify.SendNotify(botTelegram, GenericNotify.NotifyRequestAnimeDTOToGenericNotify(notify), chat_id);

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Cesxhin.AnimeManga.Application.Notify;
using Cesxhin.AnimeManga.Modules.NlogManager;
using Cesxhin.AnimeManga.Domain.DTO;
using Discord.Webhook;
using MassTransit;
using NLog;
using System;
using System.Threading.Tasks;

namespace Cesxhin.AnimeManga.Application.Consumers
{
public class NotifyVideoConsumer : IConsumer<NotifyAnimeDTO>
{
//nlog
private readonly NLogConsole _logger = new(LogManager.GetCurrentClassLogger());

//webhook discord
private readonly string _webhookDiscord = Environment.GetEnvironmentVariable("WEBHOOK_DISCORD_VIDEO");

public Task Consume(ConsumeContext<NotifyAnimeDTO> context)
{
DiscordWebhookClient discord = new(_webhookDiscord);
var managementNotify = new NotifyDiscord();

var notify = context.Message;
_logger.Info($"Recive this message: {notify.Message}");

managementNotify.SendNotify(discord, GenericNotify.NotifyAnimeDTOToGenericNotify(notify), null);

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Cesxhin.AnimeManga.Application.Notify;
using Cesxhin.AnimeManga.Modules.NlogManager;
using Cesxhin.AnimeManga.Domain.DTO;
using MassTransit;
using NLog;
using System;
using System.Threading.Tasks;
using Telegram.Bot;

namespace Cesxhin.AnimeManga.Application.Consumers
{
public class NotifyVideoTelegramConsumer : IConsumer<NotifyAnimeDTO>
{
//nlog
private readonly NLogConsole _logger = new(LogManager.GetCurrentClassLogger());

//settings for bot telegram
private readonly string tokenBot = Environment.GetEnvironmentVariable("TOKEN_BOT");
private readonly string chat_id = Environment.GetEnvironmentVariable("CHAT_ID");

public Task Consume(ConsumeContext<NotifyAnimeDTO> context)
{
var botTelegram = new TelegramBotClient(tokenBot);
var managementNotify = new NotifyTelegramChannel();

var notify = context.Message;
_logger.Info($"Recive this message: {context.MessageId}");

managementNotify.SendNotify(botTelegram, GenericNotify.NotifyAnimeDTOToGenericNotify(notify), chat_id);

return Task.CompletedTask;
}
}
}
9 changes: 9 additions & 0 deletions src/Cesxhin.AnimeManga.Application/Notify/Notify.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Discord.Webhook;

namespace Cesxhin.AnimeManga.Application.Notify
{
public abstract class Notify<S, T>
{
public abstract void SendNotify(S whereSend, T notify, string token);
}
}
Loading
Loading