Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Deliay committed Dec 29, 2024
1 parent 6f29d54 commit ac4e12d
Show file tree
Hide file tree
Showing 133 changed files with 1,303 additions and 6,586 deletions.
11 changes: 1 addition & 10 deletions Mikibot.Analyze/Bot/AiImageGenerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,14 @@
using Mirai.Net.Data.Messages;
using Mirai.Net.Data.Messages.Concretes;
using Mirai.Net.Data.Messages.Receivers;
using Mirai.Net.Sessions.Http.Managers;
using Mirai.Net.Utils.Scaffolds;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Text.Json;
using System.Threading.Channels;
using System.Threading.Tasks;
using Websocket.Client.Logging;
using Mikibot.BuildingBlocks.Util;
using NPOI.Util;
using Mikibot.StableDiffusion.WebUi.Api.Models;
using NPOI.SS.Formula.Functions;
using Mikibot.Analyze.Service;
using Mikibot.StableDiffusion.WebUi.Api.Models;
using QWeatherAPI.Result.WeatherDailyForecast;
using QWeatherAPI.Result.GeoAPI.CityLookup;

Expand Down
8 changes: 0 additions & 8 deletions Mikibot.Analyze/Bot/AiVoiceGenerationService.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
using FFMpegCore;
using FFMpegCore.Pipes;
using Microsoft.Extensions.Logging;
using Mikibot.Analyze.Generic;
using Mikibot.Analyze.MiraiHttp;
using Mirai.Net.Data.Messages;
using Mirai.Net.Data.Messages.Concretes;
using Mirai.Net.Data.Messages.Receivers;
using Mirai.Net.Sessions.Http.Managers;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Threading.Channels;
using System.Threading.Tasks;

namespace Mikibot.Analyze.Bot
{
Expand Down
6 changes: 0 additions & 6 deletions Mikibot.Analyze/Bot/AntiBoyFriendFanVoiceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
using Mirai.Net.Data.Messages;
using Mirai.Net.Data.Messages.Concretes;
using Mirai.Net.Data.Messages.Receivers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Channels;
using System.Threading.Tasks;

namespace Mikibot.Analyze.Bot
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,96 +1,89 @@
using Microsoft.Extensions.Logging;
using Mikibot.Analyze.Generic;
using Mikibot.Analyze.MiraiHttp;
using Mikibot.Crawler.Http.Bilibili;
using Mirai.Net.Data.Messages;
using Mirai.Net.Data.Messages.Concretes;
using Mirai.Net.Data.Messages.Receivers;
using Mirai.Net.Data.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;

namespace Mikibot.Analyze.Bot
{
public class BiliBiliVideoLinkShareProxerService(
IMiraiService miraiService,
ILogger<BiliBiliVideoLinkShareProxerService> logger,
BiliVideoCrawler crawler) : MiraiGroupMessageProcessor<BiliBiliVideoLinkShareProxerService>(miraiService, logger)
{
private BiliVideoCrawler Crawler => crawler;

public async ValueTask TrySend(Group group, string? bv, string? av, CancellationToken token)
{
try
{
var result = await Crawler.GetVideoInfo(bv, av == null ? null : int.Parse(av!), token);

await MiraiService.SendMessageToGroup(group, token,
[
new ImageMessage()
{
Url = result.CoverUrl,
},
new PlainMessage($"{result.Title} (作者: {result.Owner.Name}) \n https://bilibili.com/{result.BvId}"),
]);
}
catch (Exception ex)
{
Logger.LogError(ex, "Error while send message");
}
}

private static readonly HashSet<char> ValidBv = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
];
private static readonly HashSet<char> ValidAv = [
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
];
private static string Fetch(string raw, int startIndex, HashSet<char> allow)
{
for (int i = startIndex + 1; i < raw.Length; i++)
{
if (!allow.Contains(raw[i]))
return raw[startIndex..i];
}
return raw[startIndex..];
}

protected override async ValueTask Process(GroupMessageReceiver message, CancellationToken token = default)
{
var group = message.Sender.Group;

foreach (var rawMsg in message.MessageChain)
{
if (rawMsg is PlainMessage plain && plain.Text.StartsWith('!'))
{
var text = plain.Text;
var bvStart = text.IndexOf("/BV");
if (bvStart > -1)
{
var bv = Fetch(text, bvStart + 1, ValidBv);
Logger.LogInformation("准备发送bv {}", bv);
await TrySend(group, bv, null, token);
break;
}

var avStart = text.IndexOf("/av");
if (avStart > -1)
{
var av = Fetch(text, avStart + 3, ValidAv);
Logger.LogInformation("准备发送av {}", av);
await TrySend(group, null, av, token);
break;
}
}
}
}
}
}
using Microsoft.Extensions.Logging;
using Mikibot.Analyze.Generic;
using Mikibot.Analyze.MiraiHttp;
using Mikibot.Crawler.Http.Bilibili;
using Mirai.Net.Data.Messages.Concretes;
using Mirai.Net.Data.Messages.Receivers;
using Mirai.Net.Data.Shared;

namespace Mikibot.Analyze.Bot
{
public class BiliBiliVideoLinkShareProxyService(
IMiraiService miraiService,
ILogger<BiliBiliVideoLinkShareProxyService> logger,
BiliVideoCrawler crawler) : MiraiGroupMessageProcessor<BiliBiliVideoLinkShareProxyService>(miraiService, logger)
{
private BiliVideoCrawler Crawler => crawler;

private async ValueTask TrySend(Group group, string? bv, string? av, CancellationToken token)
{
try
{
var result = await Crawler.GetVideoInfo(bv, av == null ? null : int.Parse(av!), token);

await MiraiService.SendMessageToGroup(group, token,
[
new ImageMessage()
{
Url = result.CoverUrl,
},
new PlainMessage($"{result.Title} (作者: {result.Owner.Name}) \n https://bilibili.com/{result.BvId}"),
]);
}
catch (Exception ex)
{
Logger.LogError(ex, "Error while send message");
}
}

private static readonly HashSet<char> ValidBv = [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
];
private static readonly HashSet<char> ValidAv = [
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
];
private static string Fetch(string raw, int startIndex, HashSet<char> allow)
{
for (int i = startIndex + 1; i < raw.Length; i++)
{
if (!allow.Contains(raw[i]))
return raw[startIndex..i];
}
return raw[startIndex..];
}

protected override async ValueTask Process(GroupMessageReceiver message, CancellationToken token = default)
{
var group = message.Sender.Group;

foreach (var rawMsg in message.MessageChain)
{
if (rawMsg is PlainMessage plain && plain.Text.StartsWith('!'))
{
var text = plain.Text;
var bvStart = text.IndexOf("/BV", StringComparison.InvariantCulture);
if (bvStart > -1)
{
var bv = Fetch(text, bvStart + 1, ValidBv);
Logger.LogInformation("准备发送bv {}", bv);
await TrySend(group, bv, null, token);
break;
}

var avStart = text.IndexOf("/av", StringComparison.InvariantCulture);
if (avStart > -1)
{
var av = Fetch(text, avStart + 3, ValidAv);
Logger.LogInformation("准备发送av {}", av);
await TrySend(group, null, av, token);
break;
}
}
}
}
}
}
8 changes: 1 addition & 7 deletions Mikibot.Analyze/Bot/MikiDanmakuProxyService.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
using Microsoft.Extensions.Logging;
using Mikibot.Analyze.MiraiHttp;
using Mikibot.Analyze.MiraiHttp;
using Mikibot.Crawler.WebsocketCrawler.Data.Commands.KnownCommand;
using Mirai.Net.Data.Messages;
using Mirai.Net.Data.Messages.Concretes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mikibot.Analyze.Bot
{
Expand Down
1 change: 0 additions & 1 deletion Mikibot.Analyze/Bot/MikiLiveEventProxyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Mikibot.Crawler.WebsocketCrawler.Data.Commands.Utils;
using Mirai.Net.Data.Messages;
using Mirai.Net.Data.Messages.Concretes;
using System.Text;

namespace Mikibot.Analyze.Bot;

Expand Down
1 change: 0 additions & 1 deletion Mikibot.Analyze/Bot/RandomImage/RandomImageService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Threading.Channels;
using Microsoft.Extensions.Logging;
using Mikibot.Analyze.Generic;
using Mikibot.Analyze.MiraiHttp;
Expand Down
38 changes: 24 additions & 14 deletions Mikibot.Analyze/Mikibot.Analyze.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyVersion>0.1.2.20</AssemblyVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="NPOI" Version="2.6.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Mirai.Net" Version="2.4.8" />
<PackageReference Include="Autofac" Version="6.5.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="NPOI" Version="2.7.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
<PackageReference Include="Polly" Version="8.5.0" />
<PackageReference Include="Mirai.Net" Version="2.5.2" />
<PackageReference Include="Autofac" Version="8.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
<PackageReference Include="QWeatherAPI" Version="1.3.3" />
<PackageReference Include="FFMpegCore" Version="5.1.0" />
<PackageReference Include="Mikibot.Crawler" Version="1.0.4" />
<PackageReference Include="Lagrange.Core" Version="0.2.1" />
<PackageReference Include="Mikibot.Crawler" Version="1.0.5" />
<PackageReference Include="Lagrange.Core" Version="0.3.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -41,6 +41,16 @@
<None Update="resources\transparent.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Compile Remove="Notification\DanmakuRecordControlService.cs" />
<None Include="Notification\Deprecated\DanmakuCollectorService.cs" />
<None Include="Notification\Deprecated\DanmakuExportGuardList.cs" />
<None Include="Notification\Deprecated\DanmakuRecordControlService.cs" />
<Compile Remove="Notification\DanmakuCollectorService.cs" />
<Compile Remove="Notification\DanmakuExportGuardList.cs" />
<Compile Remove="Notification\DanmakuSpeedStatisticService.cs" />
<None Include="Notification\Deprecated\DanmakuSpeedStatisticService.cs" />
<Compile Remove="Service\Deprecated\LiveStreamEventService.cs" />
<None Include="Service\Deprecated\LiveStreamEventService.cs" />
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions Mikibot.Analyze/MiraiHttp/ConsoleMiraiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
using Mirai.Net.Data.Messages.Concretes;
using Mirai.Net.Data.Messages.Receivers;
using Mirai.Net.Data.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mikibot.Analyze.MiraiHttp
{
Expand Down
8 changes: 1 addition & 7 deletions Mikibot.Analyze/MiraiHttp/MiraiBotConfig.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mikibot.Analyze.MiraiHttp
namespace Mikibot.Analyze.MiraiHttp
{
public struct MiraiBotConfig
{
Expand Down
7 changes: 0 additions & 7 deletions Mikibot.Analyze/MiraiHttp/MiraiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
using Mirai.Net.Data.Shared;
using Mirai.Net.Sessions;
using Mirai.Net.Sessions.Http.Managers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reactive;
using System.Threading.Tasks;
using System.Reactive.Linq;
using Mikibot.Crawler.Http.Bilibili;

namespace Mikibot.Analyze.MiraiHttp
{
Expand Down
Loading

0 comments on commit ac4e12d

Please sign in to comment.