qqbot
This commit is contained in:
parent
8c98935588
commit
4ef763c70b
@ -12,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决
|
||||
main.md = main.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "qqbot", "qqbot\qqbot.csproj", "{48194663-D4E2-40CE-9ED0-9A7459ABA9AD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -24,10 +22,6 @@ Global
|
||||
{6BBCCC2C-1B0A-4456-B9E5-B0EF2B156D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6BBCCC2C-1B0A-4456-B9E5-B0EF2B156D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6BBCCC2C-1B0A-4456-B9E5-B0EF2B156D8B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{48194663-D4E2-40CE-9ED0-9A7459ABA9AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{48194663-D4E2-40CE-9ED0-9A7459ABA9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{48194663-D4E2-40CE-9ED0-9A7459ABA9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{48194663-D4E2-40CE-9ED0-9A7459ABA9AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -16,6 +16,17 @@ using static asg_form.Controllers.InviteReferee;
|
||||
|
||||
namespace asg_form.Controllers
|
||||
{
|
||||
|
||||
class qquser
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string qqid { get; set; }
|
||||
public int money { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
class FormConfig : IEntityTypeConfiguration<form>
|
||||
{
|
||||
class forcomConfig : IEntityTypeConfiguration<comform.com_form>
|
||||
@ -257,6 +268,7 @@ namespace asg_form.Controllers
|
||||
public DbSet<comform.com_form> com_Forms { get; set; }
|
||||
public DbSet<T_Friend> T_Friends { get; set; }
|
||||
public DbSet<StoreDB> T_Store { get; set; }
|
||||
public DbSet<qquser> Qqusers { get; set; }
|
||||
public DbSet<StoreinfoDB> T_Storeinfo { get; set; }
|
||||
public DbSet<T_config> T_config { get; set; }
|
||||
public DbSet<TaskDB> T_Task { get; set; }
|
||||
|
@ -24,6 +24,11 @@ using Mirai.Net.Sessions.Http.Managers;
|
||||
using asg_form.Controllers.Store;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using static asg_form.Controllers.Store.Storehttp;
|
||||
using Flandre.Framework;
|
||||
using Flandre.Core.Common;
|
||||
using Flandre.Core.Messaging;
|
||||
using Mirai.Net.Data.Messages.Concretes;
|
||||
using Flandre.Core.Messaging.Segments;
|
||||
|
||||
namespace asg_form.Controllers
|
||||
{
|
||||
@ -128,28 +133,20 @@ namespace asg_form.Controllers
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
|
||||
public async Task<ActionResult<object>> post_qqbotmsg([FromBody] string msg,string qqgrope,bool is_atall)
|
||||
public async Task<ActionResult<object>> post_qqbotmsg([FromBody] string msg,string qqgrope,string atuserqq)
|
||||
{
|
||||
|
||||
if (!this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
||||
{
|
||||
return BadRequest(new error_mb { code = 400, message = "无权访问" });
|
||||
}
|
||||
if(is_atall){
|
||||
var messageChain = new MessageChainBuilder()
|
||||
.AtAll()
|
||||
.Plain(msg)
|
||||
.Build();
|
||||
await MessageManager.SendGroupMessageAsync(qqgrope, messageChain);
|
||||
var message= new MessageBuilder().Add(new AtSegment(atuserqq)).Text(msg).Build();
|
||||
|
||||
await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel,null,null,message,qqgrope);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
var messageChain = new MessageChainBuilder()
|
||||
.Plain(msg)
|
||||
.Build();
|
||||
await MessageManager.SendGroupMessageAsync(qqgrope, messageChain);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return Ok("成功!");
|
||||
|
1057
asg_form/Migrations/20241019054314_qqbot1.Designer.cs
generated
Normal file
1057
asg_form/Migrations/20241019054314_qqbot1.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
88
asg_form/Migrations/20241019054314_qqbot1.cs
Normal file
88
asg_form/Migrations/20241019054314_qqbot1.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace asg_form.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class qqbot1 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreationTime",
|
||||
table: "AspNetUsers");
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "com_limit",
|
||||
table: "F_game",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "judge",
|
||||
table: "F_game",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "person_type",
|
||||
table: "F_game",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "T_Task",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
chinaname = table.Column<string>(type: "text", nullable: false),
|
||||
createPerson = table.Column<string>(type: "text", nullable: false),
|
||||
createUserId = table.Column<long>(type: "bigint", nullable: true),
|
||||
userId = table.Column<long>(type: "bigint", nullable: false),
|
||||
taskName = table.Column<string>(type: "text", nullable: false),
|
||||
taskDescription = table.Column<string>(type: "text", nullable: false),
|
||||
status = table.Column<string>(type: "text", nullable: false),
|
||||
money = table.Column<long>(type: "bigint", nullable: false),
|
||||
createTime = table.Column<string>(type: "text", nullable: false),
|
||||
lastOperateTime = table.Column<string>(type: "text", nullable: false),
|
||||
approvalPerson = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_T_Task", x => x.id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "T_Task");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "com_limit",
|
||||
table: "F_game");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "judge",
|
||||
table: "F_game");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "person_type",
|
||||
table: "F_game");
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreationTime",
|
||||
table: "AspNetUsers",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
}
|
||||
}
|
||||
}
|
@ -351,6 +351,60 @@ namespace asg_form.Migrations
|
||||
b.ToTable("F_events", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("asg_form.Controllers.TaskDB", b =>
|
||||
{
|
||||
b.Property<long>("id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("id"));
|
||||
|
||||
b.Property<string>("approvalPerson")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("chinaname")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("createPerson")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("createTime")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long?>("createUserId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("lastOperateTime")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("money")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("status")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("taskDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("taskName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<long>("userId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.HasKey("id");
|
||||
|
||||
b.ToTable("T_Task", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("asg_form.Controllers.Team.T_Player", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@ -612,13 +666,22 @@ namespace asg_form.Migrations
|
||||
b.Property<string>("bilibiliuri")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("com_limit")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("commentary")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("judge")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("opentime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("person_type")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("referee")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@ -696,9 +759,6 @@ namespace asg_form.Migrations
|
||||
.IsConcurrencyToken()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("CreationTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
@ -1,6 +1,8 @@
|
||||
using asg_form;
|
||||
using asg_form.Controllers;
|
||||
using asg_form.Controllers.Hubs;
|
||||
using Flandre.Adapters.OneBot.Extensions;
|
||||
using Flandre.Framework;
|
||||
using IGeekFan.AspNetCore.Knife4jUI;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
@ -77,12 +79,43 @@ options.AddDefaultPolicy(builder => builder.WithOrigins(urls)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var builder1 = FlandreApp.CreateBuilder(new HostApplicationBuilderSettings
|
||||
{
|
||||
Args = args,
|
||||
ContentRootPath = AppDomain.CurrentDomain.BaseDirectory
|
||||
});
|
||||
|
||||
// 安装一个适配器,并添加在这里。
|
||||
// builder.Adapters.Add(new YourAdapter());
|
||||
builder1.Adapters.AddOneBot(builder.Configuration.GetSection("Adapters:OneBot"));
|
||||
builder1.Plugins.Add<qqbot>();
|
||||
var app1 = builder1.Build();
|
||||
// 添加内置中间件。
|
||||
// 这些中间件保证 Flandre 的正常运转。你也可以加入自己的中间件,并灵活调整其顺序。
|
||||
app1.UseCommandSession();
|
||||
// app.UseMiddleware(async (ctx, next) => { /* ... */ });
|
||||
app1.UseCommandParser();
|
||||
app1.UseCommandInvoker();
|
||||
runbot.runbotr = app1.Bots.First();
|
||||
app1.Run();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
IServiceCollection services = builder.Services;
|
||||
|
||||
|
||||
var eventBusSec = builder.Configuration.GetSection("EventBus");
|
||||
builder.Services.Configure<IntegrationEventRabbitMQOptions>(eventBusSec);
|
||||
builder.Services.AddEventBus("qqbot_server", Assembly.GetExecutingAssembly());
|
||||
|
||||
services.AddDbContext<IDBcontext>(opt =>
|
||||
{
|
||||
|
@ -27,8 +27,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0-beta.1" />
|
||||
<PackageReference Include="ChatGPT.Net" Version="2.0.0" />
|
||||
<PackageReference Include="EntityFrameworkCore.DataEncryption" Version="5.0.0" />
|
||||
<PackageReference Include="Flandre.Adapters.OneBot.Extensions" Version="2.0.0-rc.3" />
|
||||
<PackageReference Include="Flandre.Core" Version="1.0.0-rc.4" />
|
||||
<PackageReference Include="Flandre.Framework" Version="1.0.0-rc.11" />
|
||||
<PackageReference Include="IGeekFan.AspNetCore.Knife4jUI" Version="0.0.16" />
|
||||
@ -64,6 +66,7 @@
|
||||
<PackageReference Include="RestSharp" Version="106.12.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.1.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="Zack.EventBus" Version="1.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
5
asg_form/libman.json
Normal file
5
asg_form/libman.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"defaultProvider": "cdnjs",
|
||||
"libraries": []
|
||||
}
|
@ -21,45 +21,238 @@ using NPOI.SS.Formula.Functions;
|
||||
using Onebot.Protocol;
|
||||
using Onebot.Protocol.Models.Messages;
|
||||
using Zack.EventBus;
|
||||
using Flandre.Framework.Common;
|
||||
using Flandre.Framework.Routing;
|
||||
using static asg_form.Controllers.InviteReferee;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Azure.Identity;
|
||||
using OpenAI.Chat;
|
||||
using Azure.AI.OpenAI;
|
||||
using Flandre.Core.Messaging;
|
||||
using Flandre.Core.Common;
|
||||
|
||||
namespace asg_form
|
||||
{
|
||||
[EventName("查询选手")]
|
||||
public class qqbot:IIntegrationEventHandler
|
||||
|
||||
public static class runbot
|
||||
{
|
||||
public static Bot runbotr { get; set; }
|
||||
}
|
||||
[EventName("查询选手")]
|
||||
public class qqbot:Plugin
|
||||
{
|
||||
private IEventBus eventBus;
|
||||
|
||||
public qqbot(IEventBus eventBus)
|
||||
[Command]
|
||||
public string 查询选手(string name)
|
||||
{
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
public Task Handle(string eventName, string eventData)
|
||||
{
|
||||
|
||||
if (eventName == "查询选手")
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
TestDbContext ctx = new TestDbContext();
|
||||
|
||||
string msg = "";
|
||||
var roles = ctx.Roles.Include(a => a.form).Where(a => a.role_name.IndexOf(eventData) >= 0).ToList();
|
||||
var roles = ctx.Roles.Include(a => a.form).Where(a => a.role_name.IndexOf(name) >= 0).ToList();
|
||||
foreach (var role in roles)
|
||||
{
|
||||
msg = $"{msg}\r\n姓名:{role.role_name}\r\n第五人格ID:{role.role_id}\r\n选手id:{role.Id}\r\n阵营:{role.role_lin}\r\n属于队伍:{role.form.team_name}\r\n";
|
||||
}
|
||||
eventBus.Publish("查询选手req",msg);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return msg ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
catch
|
||||
{
|
||||
return "出现错误";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Command]
|
||||
public string 近期赛程()
|
||||
{
|
||||
try
|
||||
{
|
||||
TestDbContext testDb = new TestDbContext();
|
||||
int q = testDb.team_Games.Count();
|
||||
var a = testDb.team_Games.Where(a => a.opentime >= DateTime.Now).Take(7);
|
||||
string msg = "";
|
||||
foreach (var b in a)
|
||||
{
|
||||
msg = $"{msg}\r\n{b.team1_name} VS {b.team2_name}\r\n时间:{b.opentime.ToString("f")}";
|
||||
}
|
||||
return msg;
|
||||
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "出现错误";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Command]
|
||||
public string 查询冠军()
|
||||
{
|
||||
try
|
||||
{
|
||||
TestDbContext ctx = new TestDbContext();
|
||||
|
||||
var teams = ctx.Champions.Include(a => a.events).Include(a => a.form.role).Select(a => new { a.form, a.events, a.msg }).ToList();
|
||||
string msg = "";
|
||||
foreach (var t in teams)
|
||||
{
|
||||
string role = "";
|
||||
|
||||
foreach (var t2 in t.form.role)
|
||||
{
|
||||
role = $"{role} {t2.role_name}";
|
||||
}
|
||||
msg = $"{msg}\r\n队伍名称:{t.form.team_name}\r\n队员:{role}\r\n属于:{t.events.name}\r\n简介:{t.msg}\r\n";
|
||||
}
|
||||
return msg;
|
||||
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "出现错误";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Command]
|
||||
public string 查询战队(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
TestDbContext ctx = new TestDbContext();
|
||||
|
||||
List<form> teams = ctx.Forms.Include(a => a.role).Where(a => a.team_name.IndexOf(name) >= 0).ToList();
|
||||
string msg = "";
|
||||
foreach (var t in teams)
|
||||
{
|
||||
string role = "";
|
||||
foreach (var t2 in t.role)
|
||||
{
|
||||
role = $"{role} {t2.role_name}";
|
||||
}
|
||||
msg = $"{msg}\r\n队伍名称:{t.team_name}\r\n队员:{role}\r\n";
|
||||
}
|
||||
return msg;
|
||||
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "出现错误";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Command]
|
||||
public async Task<string> 抱抱罗比(MessageContext ctx)
|
||||
{
|
||||
try
|
||||
{
|
||||
using(TestDbContext testDb=new TestDbContext())
|
||||
{
|
||||
Random ran = new Random();
|
||||
int n = ran.Next(100, 200);
|
||||
|
||||
if (!testDb.Qqusers.Any(a => a.qqid == ctx.UserId))
|
||||
{
|
||||
await testDb.Qqusers.AddAsync(new qquser { qqid = ctx.UserId, money = n });
|
||||
}
|
||||
else
|
||||
{
|
||||
var user=await testDb.Qqusers.FirstAsync(a=>a.qqid == ctx.UserId);
|
||||
user.money += n;
|
||||
|
||||
}
|
||||
await testDb.SaveChangesAsync();
|
||||
return $"罗比很开心\r\n给你棒棒糖:{n.ToString()}个";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "出现错误";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Command]
|
||||
public string ai(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
AzureOpenAIClient azureClient = new(
|
||||
new Uri("https://dashscope.aliyuncs.com/compatible-mode/v1"),
|
||||
new System.ClientModel.ApiKeyCredential("sk-c6f37689f4014b5bbf5fd8b2e872d20b"));
|
||||
ChatClient chatClient = azureClient.GetChatClient("qwen-turbo");
|
||||
|
||||
ChatCompletion completion = chatClient.CompleteChat(
|
||||
[
|
||||
// System messages represent instructions or other guidance about how the assistant should behave
|
||||
new UserChatMessage("我们来玩角色扮演接下来你是一个没有父母但很喜欢姐姐的一个小男孩"),
|
||||
new UserChatMessage(msg),
|
||||
]);
|
||||
|
||||
return completion.Content[0].Text;
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "出现错误";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Command]
|
||||
public string aimath(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
AzureOpenAIClient azureClient = new(
|
||||
new Uri("https://dashscope.aliyuncs.com/compatible-mode/v1"),
|
||||
new System.ClientModel.ApiKeyCredential("sk-c6f37689f4014b5bbf5fd8b2e872d20b"));
|
||||
ChatClient chatClient = azureClient.GetChatClient("qwen-math-plus");
|
||||
|
||||
ChatCompletion completion = chatClient.CompleteChat(
|
||||
[
|
||||
// System messages represent instructions or other guidance about how the assistant should behave
|
||||
|
||||
new UserChatMessage(msg),
|
||||
]);
|
||||
|
||||
return completion.Content[0].Text;
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "出现错误";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static bool isToday(DateTime dt)
|
||||
{
|
||||
DateTime today = DateTime.Today;
|
||||
@ -104,55 +297,7 @@ namespace asg_form
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (x.MessageChain.GetPlainMessage() == "近期赛程")
|
||||
// {
|
||||
// TestDbContext testDb = new TestDbContext();
|
||||
// int q = testDb.team_Games.Count();
|
||||
// var a = testDb.team_Games.Where(a => a.opentime >= DateTime.Now).Take(7);
|
||||
// string msg = "";
|
||||
// foreach (var b in a)
|
||||
// {
|
||||
// msg = $"{msg}\r\n{b.team1_name} VS {b.team2_name}\r\n时间:{b.opentime.ToString("f")}";
|
||||
// }
|
||||
// await MessageManager.SendGroupMessageAsync(x.GroupId, msg);
|
||||
// }
|
||||
// if (x.MessageChain.GetPlainMessage() == "后端状态")
|
||||
// {
|
||||
// string msg = $"CPU占用:{SystemInfo.CpuLoad.ToString("f2")}\r\n内存占用:{SystemInfo.MemoryAvailable.ToString("f2")}\r\n部署系统:{Windows.GetOsVersion()}";
|
||||
|
||||
// await MessageManager.SendGroupMessageAsync(x.GroupId, msg);
|
||||
// }
|
||||
// if (x.MessageChain.GetPlainMessage() == "参赛队伍")
|
||||
// {
|
||||
// TestDbContext testDb = new TestDbContext();
|
||||
// var team = testDb.Forms.Select(a => a.team_name);
|
||||
// string msg = "";
|
||||
// foreach (var t in team)
|
||||
// {
|
||||
// msg = $"{msg} {t}";
|
||||
// }
|
||||
// await MessageManager.SendGroupMessageAsync(x.GroupId, $"在所有比赛中有以下队伍参赛:\r\n{string.Join(" , ",team)}");
|
||||
|
||||
// }
|
||||
// if (x.MessageChain.GetPlainMessage() == "查询冠军")
|
||||
// {
|
||||
// TestDbContext ctx = new TestDbContext();
|
||||
|
||||
// var teams = ctx.Champions.Include(a=>a.events).Include(a=>a.form.role).Select(a => new {a.form,a.events,a.msg}).ToList();
|
||||
// string msg = "";
|
||||
// foreach (var t in teams)
|
||||
// {
|
||||
// string role = "";
|
||||
|
||||
// foreach (var t2 in t.form.role)
|
||||
// {
|
||||
// role = $"{role} {t2.role_name}";
|
||||
// }
|
||||
// msg = $"{msg}\r\n队伍名称:{t.form.team_name}\r\n队员:{role}\r\n属于:{t.events.name}\r\n简介:{t.msg}\r\n";
|
||||
// }
|
||||
// await MessageManager.SendGroupMessageAsync(x.GroupId, $"拥有以下冠军:{msg}");
|
||||
|
||||
// }
|
||||
// }
|
||||
// catch(Exception ex)
|
||||
// {
|
||||
|
22
qqbot/sendmsg.cs
Normal file
22
qqbot/sendmsg.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Zack.EventBus;
|
||||
|
||||
namespace qqbot
|
||||
{
|
||||
[EventName("查询选手req")]
|
||||
internal class sendmsg : IIntegrationEventHandler
|
||||
{
|
||||
public Task Handle(string eventName, string eventData)
|
||||
{
|
||||
if (eventName == "查询选手req")
|
||||
{
|
||||
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user