QQ机器人

This commit is contained in:
杨毅 2025-02-02 16:26:04 +08:00
parent f40c0453eb
commit 500202946d
4 changed files with 36 additions and 14 deletions

View File

@ -123,23 +123,19 @@ namespace asg_form.Controllers
{ {
using(TestDbContext testDb = new TestDbContext()) { using(TestDbContext testDb = new TestDbContext()) {
var user = await userManager.FindByNameAsync(this.User.Identity!.Name!); var user = await userManager.FindByNameAsync(this.User.Identity!.Name!);
if (user.officium != "Anchor")
{
return Ok(new error_mb { code = 401, message = $"你是{user.officium},你不是导播,无法操作" });
}
else
{
//对testDb.team_Games.commentary中出现最多的十个解说名称进行排名 //对testDb.team_Games.commentary中出现最多的十个解说名称进行排名
var ranking = testDb.team_Games.SelectMany(g => JsonConvert.DeserializeObject<List<com_json>>(g.commentary).Select(c => c.chinaname)) var ranking = testDb.team_Games.ToList();
var ranking1= ranking.SelectMany(g => JsonConvert.DeserializeObject<List<com_json>>(g.commentary).Select(c => c.chinaname))
.GroupBy(c => c) .GroupBy(c => c)
.OrderByDescending(g => g.Count()) .OrderByDescending(g => g.Count())
.Take(10) .Take(10)
.Select(g => new { Name = g.Key, Count = g.Count() }) .Select(g => new { Name = g.Key, Count = g.Count() })
.ToList(); .ToList();
return ranking; return ranking1;
}
} }
} }

View File

@ -3,7 +3,6 @@ using asg_form.Controllers;
using asg_form.Controllers.Hubs; using asg_form.Controllers.Hubs;
using Flandre.Adapters.OneBot.Extensions; using Flandre.Adapters.OneBot.Extensions;
using Flandre.Framework; using Flandre.Framework;
using IGeekFan.AspNetCore.Knife4jUI;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;

View File

@ -33,7 +33,6 @@
<PackageReference Include="EPPlus" /> <PackageReference Include="EPPlus" />
<PackageReference Include="Flandre.Adapters.OneBot.Extensions" /> <PackageReference Include="Flandre.Adapters.OneBot.Extensions" />
<PackageReference Include="Flandre.Core" /> <PackageReference Include="Flandre.Core" />
<PackageReference Include="IGeekFan.AspNetCore.Knife4jUI" />
<PackageReference Include="MailKit" /> <PackageReference Include="MailKit" />
<PackageReference Include="Masuit.Tools.Abstractions" /> <PackageReference Include="Masuit.Tools.Abstractions" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" />

View File

@ -38,9 +38,6 @@ namespace asg_form
[EventName("查询选手")] [EventName("查询选手")]
public class qqbot:Plugin public class qqbot:Plugin
{ {
[Command] [Command]
public string (string name) public string (string name)
{ {
@ -66,6 +63,37 @@ namespace asg_form
} }
[Command]
public string ()
{
try
{
using (TestDbContext ctx = new TestDbContext())
{
var blacks= ctx.T_blacks.ToList();
string msg = "为了良好的赛事环境,我们对以下选手进行禁赛处理";
foreach (var b in blacks)
{
msg = $"{msg}\r\n{b.record_name} {b.violator} {b.platform_record} {b.offending_details} {b.processing_result} {b.feature_id}";
}
return msg;
}
}
catch
{
return "出现错误";
}
}
[Command] [Command]
public string () public string ()
{ {