This commit is contained in:
杨毅 2024-10-19 20:40:45 +08:00
parent 81447acb4a
commit b8b1c59875
2 changed files with 29 additions and 0 deletions

View File

@ -21,6 +21,7 @@ namespace asg_form
public string? chinaname { get; set; }
public string? officium { get; set; }
public string? qqnumber { get; set; }
public int point { get; set; }

View File

@ -32,6 +32,7 @@ using Flandre.Core.Messaging;
using Flandre.Core.Common;
using Microsoft.OpenApi.Models;
using Flurl.Http;
using Microsoft.AspNetCore.Identity;
namespace asg_form
{
@ -44,6 +45,16 @@ namespace asg_form
public class qqbot:Plugin
{
private readonly RoleManager<Role> roleManager;
private readonly UserManager<User> userManager;
public qqbot(
RoleManager<Role> roleManager, UserManager<User> userManager)
{
this.roleManager = roleManager;
this.userManager = userManager;
}
[Command]
public string (string name)
{
@ -229,6 +240,23 @@ namespace asg_form
[Command]
public async Task<string> QQ(string username, MessageContext ctx)
{
try
{
var user= await userManager.FindByNameAsync(username);
user.qqnumber = ctx.UserId;
await userManager.UpdateAsync(user);
return $"绑定成功!\r\n姓名{user.chinaname}";
}
catch (Exception ex)
{
return $"出现错误{ex.Message}";
}
}
[Command]
public async Task<string> ai(string msg)
{