Skip to content

Commit 3b7002a

Browse files
committed
Upgrade to net 9.0 and update packages
1 parent b88dbd8 commit 3b7002a

23 files changed

+188
-183
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<ImplicitUsings>true</ImplicitUsings>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
11+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
1212
<PackageReference Include="NetVips.Native.linux-x64" Version="8.11.3.1" Condition="$([MSBuild]::IsOsPlatform('Linux'))" />
1313
<PackageReference Include="NetVips.Native.osx-x64" Version="8.11.3.1" Condition="$([MSBuild]::IsOsPlatform('OSX'))" />
14-
<PackageReference Include="NetVips" Version="2.4.1" />
15-
<PackageReference Include="NetVips.Native.win-x64" Version="8.15.2" />
14+
<PackageReference Include="NetVips" Version="3.0.0" />
15+
<PackageReference Include="NetVips.Native.win-x64" Version="8.16.0" />
1616
</ItemGroup>
1717

1818
</Project>

Source/WetPicsRebirth.Tests/WetPicsRebirth.Tests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<ImplicitUsings>true</ImplicitUsings>
@@ -10,11 +10,11 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Bogus" Version="35.5.0" />
14-
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
16-
<PackageReference Include="xunit" Version="2.7.1" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.8">
13+
<PackageReference Include="Bogus" Version="35.6.1" />
14+
<PackageReference Include="FluentAssertions" Version="7.0.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
16+
<PackageReference Include="xunit" Version="2.9.2" />
17+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
<PrivateAssets>all</PrivateAssets>
2020
</PackageReference>

Source/WetPicsRebirth.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
1616
..\.github\workflows\main.yml = ..\.github\workflows\main.yml
1717
EndProjectSection
1818
EndProject
19+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{216980EC-4BF9-4265-BFEC-5DA4251F0C1E}"
20+
ProjectSection(SolutionItems) = preProject
21+
global.json = global.json
22+
EndProjectSection
23+
EndProject
1924
Global
2025
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2126
Debug|Any CPU = Debug|Any CPU

Source/WetPicsRebirth/Commands/ServiceCommands/CheckPostQueryHandler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public CheckPostQueryHandler(
2525
_logger = logger;
2626
}
2727

28-
public async Task<bool> Handle(CheckPostQuery request, CancellationToken cancellationToken)
28+
public async Task<bool> Handle(CheckPostQuery request, CancellationToken ct)
2929
{
3030
try
3131
{
32-
return await HandleInternal(request, cancellationToken);
32+
return await HandleInternal(request, ct);
3333
}
3434
catch (Exception e)
3535
{
@@ -38,7 +38,7 @@ public async Task<bool> Handle(CheckPostQuery request, CancellationToken cancell
3838
}
3939
}
4040

41-
private async Task<bool> HandleInternal(CheckPostQuery request, CancellationToken cancellationToken)
41+
private async Task<bool> HandleInternal(CheckPostQuery request, CancellationToken ct)
4242
{
4343
var post = request.Post;
4444
var hash = post.PostHeader.Md5Hash ?? GetHash(post.File);
@@ -50,13 +50,13 @@ private async Task<bool> HandleInternal(CheckPostQuery request, CancellationToke
5050

5151
var file = _telegramPreparer.Prepare(post.File, post.FileSize);
5252

53-
var sentPost = await _telegramBotClient.SendPhotoAsync(
53+
var sentPost = await _telegramBotClient.SendPhoto(
5454
chatId: request.ModeratorId,
5555
photo: InputFile.FromStream(file, post.FileName),
5656
caption: post.PostHtmlCaption,
5757
parseMode: ParseMode.Html,
5858
replyMarkup: Keyboards.WithModeration,
59-
cancellationToken: cancellationToken);
59+
cancellationToken: ct);
6060

6161
await _moderatedPostsRepository.Add(post.PostHeader.Id, hash, sentPost.MessageId);
6262

Source/WetPicsRebirth/Commands/ServiceCommands/Posting/PostNext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private static bool ShouldSkip(LoadedPost loadedPost)
181181
{
182182
await using var file = _telegramPreparer.Prepare(post.File, post.FileSize);
183183

184-
var sentPost = await _telegramBotClient.SendPhotoAsync(
184+
var sentPost = await _telegramBotClient.SendPhoto(
185185
chatId: actress.ChatId,
186186
photo: InputFile.FromStream(file, post.FileName),
187187
caption: caption,
@@ -199,7 +199,7 @@ private static bool ShouldSkip(LoadedPost loadedPost)
199199

200200
private async Task<(Message sentPost, string fileId)> SendVideo(Actress actress, Post post, string caption)
201201
{
202-
var sentPost = await _telegramBotClient.SendVideoAsync(
202+
var sentPost = await _telegramBotClient.SendVideo(
203203
actress.ChatId,
204204
InputFile.FromStream(post.File, post.FileName),
205205
caption: caption,

Source/WetPicsRebirth/Commands/ServiceCommands/Posting/PostTop.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ private async Task PostTopForScene(TopType topType, Scene scene, IReadOnlyCollec
6969
if (!fileIds.Any())
7070
return;
7171

72-
var topMessage = await _telegramBotClient.SendMediaGroupAsync(scene.ChatId, fileIds);
73-
await _telegramBotClient.PinChatMessageAsync(scene.ChatId, topMessage[0].MessageId);
72+
var topMessage = await _telegramBotClient.SendMediaGroup(scene.ChatId, fileIds);
73+
await _telegramBotClient.PinChatMessage(scene.ChatId, topMessage[0].MessageId);
7474
}
7575

7676
private static string GetCaption(TopType topType, IReadOnlyCollection<PostedMedia> topMedia)

Source/WetPicsRebirth/Commands/UserCommands/Abstract/MessageHandler.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ protected MessageHandler(
2727
_handlerName = GetType().FullName!;
2828
}
2929

30-
public async Task Handle(MessageNotification notification, CancellationToken cancellationToken)
30+
public async Task Handle(MessageNotification notification, CancellationToken ct)
3131
{
3232
try
3333
{
34-
var command = await GetCommand(notification.Message, cancellationToken);
34+
var command = await GetCommand(notification.Message, ct);
3535

3636
if (!WantHandle(notification.Message, command))
3737
return;
3838

3939
_logger.LogInformation("Command received {Command} by {Handler}", command, _handlerName);
40-
await Handle(notification.Message, command, cancellationToken);
40+
await Handle(notification.Message, command, ct);
4141
}
4242
catch (Exception e)
4343
{
@@ -50,9 +50,9 @@ public async Task Handle(MessageNotification notification, CancellationToken can
5050
}
5151
}
5252

53-
private async Task<string?> GetCommand(Message message, CancellationToken cancellationToken)
53+
private async Task<string?> GetCommand(Message message, CancellationToken ct)
5454
{
55-
var me = await GetUser(cancellationToken);
55+
var me = await GetUser(ct);
5656
var botUsername = me.Username!;
5757

5858
var text = message.Text;
@@ -67,28 +67,28 @@ public async Task Handle(MessageNotification notification, CancellationToken can
6767
return command;
6868
}
6969

70-
private async Task<User> GetUser(CancellationToken cancellationToken)
70+
private async Task<User> GetUser(CancellationToken ct)
7171
{
7272
return await _memoryCache.GetRequiredOrCreateAsync(
7373
MeMemoryCacheKey,
7474
entry =>
7575
{
7676
entry.SetAbsoluteExpiration(TimeSpan.FromMinutes(10));
77-
return _telegramBotClient.GetMeAsync(cancellationToken);
77+
return _telegramBotClient.GetMe(ct);
7878
});
7979
}
8080

8181
public virtual IEnumerable<string> ProvidedCommands => Array.Empty<string>();
8282

8383
protected abstract bool WantHandle(Message message, string? command);
8484

85-
protected abstract Task Handle(Message message, string? command, CancellationToken cancellationToken);
85+
protected abstract Task Handle(Message message, string? command, CancellationToken ct);
8686

8787
protected async Task<bool> CheckOnAdmin(long targetChatId, long userId)
8888
{
8989
try
9090
{
91-
var admins = await _telegramBotClient.GetChatAdministratorsAsync(new ChatId(targetChatId));
91+
var admins = await _telegramBotClient.GetChatAdministrators(new ChatId(targetChatId));
9292

9393
var isAdmin = admins.FirstOrDefault(x => x.User.Id == userId);
9494

Source/WetPicsRebirth/Commands/UserCommands/Actresses/AddActressCommandHandler.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,72 +37,72 @@ public override IEnumerable<string> ProvidedCommands
3737

3838
protected override bool WantHandle(Message message, string? command) => command == "/addactress";
3939

40-
protected override async Task Handle(Message message, string? command, CancellationToken cancellationToken)
40+
protected override async Task Handle(Message message, string? command, CancellationToken ct)
4141
{
4242
var parameters = message.Text?.Split(' ') ?? Array.Empty<string>();
4343

4444
if (parameters.Length != 4)
4545
{
46-
await _telegramBotClient.SendTextMessageAsync(
46+
await _telegramBotClient.SendMessage(
4747
message.Chat.Id,
4848
"Команда должна выглядеть как /addactress -1001411191119 yandere month, " +
4949
"где первый параметр это айди чата или канала, " +
5050
"второй — источник картинок, " +
5151
"третий — параметр источника.",
52-
replyToMessageId: message.MessageId,
53-
cancellationToken: cancellationToken);
52+
replyParameters: message.MessageId,
53+
cancellationToken: ct);
5454
return;
5555
}
5656

5757
if (!long.TryParse(parameters[1], out var targetId))
5858
{
59-
await _telegramBotClient.SendTextMessageAsync(
59+
await _telegramBotClient.SendMessage(
6060
message.Chat.Id,
6161
"Неверный айди чата или канала",
62-
replyToMessageId: message.MessageId,
63-
cancellationToken: cancellationToken);
62+
replyParameters: message.MessageId,
63+
cancellationToken: ct);
6464
return;
6565
}
6666

6767
if (!await CheckOnAdmin(targetId, message.From!.Id))
6868
{
69-
await _telegramBotClient.SendTextMessageAsync(
69+
await _telegramBotClient.SendMessage(
7070
message.Chat.Id,
7171
"У вас должны быть права администратора в выбранном чате или канале",
72-
replyToMessageId: message.MessageId,
73-
cancellationToken: cancellationToken);
72+
replyParameters: message.MessageId,
73+
cancellationToken: ct);
7474
return;
7575
}
7676

7777
if (!TryGetImageSource(parameters[2], out var source))
7878
{
79-
await _telegramBotClient.SendTextMessageAsync(
79+
await _telegramBotClient.SendMessage(
8080
message.Chat.Id,
8181
"Неверный источник, доступны: pixiv, yandere, danbooru",
82-
replyToMessageId: message.MessageId,
83-
cancellationToken: cancellationToken);
82+
replyParameters: message.MessageId,
83+
cancellationToken: ct);
8484
return;
8585
}
8686

8787
if (!TryGetImageSourceOptions(parameters[3], source, out var options))
8888
{
89-
await _telegramBotClient.SendTextMessageAsync(
89+
await _telegramBotClient.SendMessage(
9090
message.Chat.Id,
9191
"Неверная опция для источника, доступны: day|week|month " +
9292
"или dailygeneral|dailyr18|weeklygeneral|weeklyr18|monthly|" +
9393
"rookie|original|bymalegeneral|bymaler18|byfemalegeneral|byfemaler18|r18g",
94-
replyToMessageId: message.MessageId,
95-
cancellationToken: cancellationToken);
94+
replyParameters: message.MessageId,
95+
cancellationToken: ct);
9696
return;
9797
}
9898

9999
await _actressesRepository.Add(targetId, source, options);
100100

101-
await _telegramBotClient.SendTextMessageAsync(
101+
await _telegramBotClient.SendMessage(
102102
message.Chat.Id,
103103
"Актрисы прихорошились и готовы к выступлению!",
104-
replyToMessageId: message.MessageId,
105-
cancellationToken: cancellationToken);
104+
replyParameters: message.MessageId,
105+
cancellationToken: ct);
106106
}
107107

108108
private static bool TryGetImageSourceOptions(
@@ -151,4 +151,4 @@ private static bool TryGetImageSource(string sourceString, out ImageSource sourc
151151
source = (ImageSource)result!;
152152
return true;
153153
}
154-
}
154+
}

Source/WetPicsRebirth/Commands/UserCommands/Actresses/GetActressesCommandHandler.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,61 +32,61 @@ public override IEnumerable<string> ProvidedCommands
3232

3333
protected override bool WantHandle(Message message, string? command) => command == "/getactresses";
3434

35-
protected override async Task Handle(Message message, string? command, CancellationToken cancellationToken)
35+
protected override async Task Handle(Message message, string? command, CancellationToken ct)
3636
{
3737
var parameters = message.Text?.Split(' ') ?? Array.Empty<string>();
3838

3939
if (parameters.Length != 2)
4040
{
41-
await _telegramBotClient.SendTextMessageAsync(
41+
await _telegramBotClient.SendMessage(
4242
message.Chat.Id,
4343
"Команда должна выглядеть как /getactress -1001411191119, " +
4444
"где параметр это айди чата или канала",
45-
replyToMessageId: message.MessageId,
46-
cancellationToken: cancellationToken);
45+
replyParameters: message.MessageId,
46+
cancellationToken: ct);
4747
return;
4848
}
4949

5050
if (!long.TryParse(parameters[1], out var targetId))
5151
{
52-
await _telegramBotClient.SendTextMessageAsync(
52+
await _telegramBotClient.SendMessage(
5353
message.Chat.Id,
5454
"Неверный айди чата или канала",
55-
replyToMessageId: message.MessageId,
56-
cancellationToken: cancellationToken);
55+
replyParameters: message.MessageId,
56+
cancellationToken: ct);
5757
return;
5858
}
5959

6060
if (!await CheckOnAdmin(targetId, message.From!.Id))
6161
{
62-
await _telegramBotClient.SendTextMessageAsync(
62+
await _telegramBotClient.SendMessage(
6363
message.Chat.Id,
6464
"У вас должны быть права администратора в выбранном чате или канале",
65-
replyToMessageId: message.MessageId,
66-
cancellationToken: cancellationToken);
65+
replyParameters: message.MessageId,
66+
cancellationToken: ct);
6767
return;
6868
}
6969

7070
var actresses = await _actressesRepository.GetForChat(targetId);
7171

7272
if (!actresses.Any())
7373
{
74-
await _telegramBotClient.SendTextMessageAsync(
74+
await _telegramBotClient.SendMessage(
7575
message.Chat.Id,
7676
"Актрисы не готовы!",
77-
replyToMessageId: message.MessageId,
78-
cancellationToken: cancellationToken);
77+
replyParameters: message.MessageId,
78+
cancellationToken: ct);
7979
return;
8080
}
8181

8282
var actressesListMessage = GetActressesListMessage(actresses);
8383

84-
await _telegramBotClient.SendTextMessageAsync(
84+
await _telegramBotClient.SendMessage(
8585
message.Chat.Id,
8686
actressesListMessage,
87-
replyToMessageId: message.MessageId,
87+
replyParameters: message.MessageId,
8888
parseMode: ParseMode.Html,
89-
cancellationToken: cancellationToken);
89+
cancellationToken: ct);
9090
}
9191

9292
private static string GetActressesListMessage(IReadOnlyCollection<Actress> actresses)
@@ -111,4 +111,4 @@ private static string GetActressesListMessage(IReadOnlyCollection<Actress> actre
111111

112112
return sb.ToString();
113113
}
114-
}
114+
}

0 commit comments

Comments
 (0)