bug
This commit is contained in:
parent
5b29ee73f3
commit
0c04933135
@ -1,4 +1,7 @@
|
||||
using Manganese.Text;
|
||||
using Flandre.Core.Common;
|
||||
using Flandre.Core.Messaging.Segments;
|
||||
using Flandre.Core.Messaging;
|
||||
using Manganese.Text;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -6,6 +9,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
using Mirai.Net.Sessions.Http.Managers;
|
||||
using Newtonsoft.Json;
|
||||
using System.Security.Claims;
|
||||
using static asg_form.Controllers.InviteReferee;
|
||||
|
||||
namespace asg_form.Controllers
|
||||
{
|
||||
@ -71,7 +75,10 @@ namespace asg_form.Controllers
|
||||
await userManager.UpdateAsync(user);
|
||||
try
|
||||
{
|
||||
await MessageManager.SendGroupMessageAsync("870248618", $"解说:\r\n{chinaname}\r\n选择了比赛:\r\n{teamgame.team1_name} VS {teamgame.team2_name}");
|
||||
var message = new MessageBuilder().Add(new AtSegment(user.qqnumber??"2667210109")).Text($"解说:\r\n{chinaname}\r\n选择了比赛:\r\n{teamgame.team1_name} VS {teamgame.team2_name}").Build();
|
||||
|
||||
await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel, "925510646", null, message, "925510646");
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -132,6 +139,17 @@ namespace asg_form.Controllers
|
||||
}
|
||||
teamgame.commentary = JsonConvert.SerializeObject(com);
|
||||
await testDb.SaveChangesAsync();
|
||||
try
|
||||
{
|
||||
var message = new MessageBuilder().Add(new AtSegment(user.qqnumber ?? "2667210109")).Text($"解说:\r\n{chinaname}\r\n取消了比赛:\r\n{teamgame.team1_name} VS {teamgame.team2_name}").Build();
|
||||
|
||||
await runbot.runbotr.SendMessageAsync(MessageEnvironment.Channel, "925510646", null, message, "925510646");
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
return "成功";
|
||||
}
|
||||
return BadRequest(new error_mb { code = 400, message = $"你是{user.officium},你不是解说,无法操作" });
|
||||
|
@ -266,11 +266,11 @@ namespace asg_form.Controllers
|
||||
var isadmin = await userManager.IsInRoleAsync(user, "admin");
|
||||
List<string> roles = (List<string>)await userManager.GetRolesAsync(user);
|
||||
if (showbase64) {
|
||||
return new post_user { id = id.ToInt64(), money = user.Integral, Base64 = user.UserBase64, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium };
|
||||
return new post_user { id = id.ToInt64(), money = user.Integral, Base64 = user.UserBase64, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium ,qqnumber=user.qqnumber};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new post_user { id = id.ToInt64(), money = user.Integral, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium };
|
||||
return new post_user { id = id.ToInt64(), money = user.Integral, name = user.UserName, chinaname = user.chinaname, email = user.Email, isadmin = isadmin, Roles = roles, officium = user.officium, qqnumber = user.qqnumber };
|
||||
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ namespace asg_form.Controllers
|
||||
public bool isadmin { get; set; }
|
||||
public string? officium { get; set; }
|
||||
public long? money { get; set; }
|
||||
|
||||
public string? qqnumber { get; set; }
|
||||
public List<string>? Roles { get; set; }
|
||||
|
||||
}
|
||||
|
54
asg_form/Controllers/qqbot.cs
Normal file
54
asg_form/Controllers/qqbot.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace asg_form.Controllers
|
||||
{
|
||||
|
||||
|
||||
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class qqbotr : ControllerBase
|
||||
{
|
||||
private readonly RoleManager<Role> roleManager;
|
||||
private readonly UserManager<User> userManager;
|
||||
public qqbotr(
|
||||
RoleManager<Role> roleManager, UserManager<User> userManager)
|
||||
{
|
||||
|
||||
this.roleManager = roleManager;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置qq号
|
||||
/// </summary>
|
||||
/// <param name="qqnumber"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<int>> qqnumber(string qqnumber)
|
||||
{
|
||||
|
||||
|
||||
string id = this.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
||||
var user = await userManager.FindByIdAsync(id);
|
||||
user.qqnumber= qqnumber;
|
||||
var r = await userManager.UpdateAsync(user);
|
||||
return Ok("修改成功");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -234,6 +234,7 @@ new Thread(o =>
|
||||
// app.UseMiddleware(async (ctx, next) => { /* ... */ });
|
||||
app1.UseCommandParser();
|
||||
app1.UseCommandInvoker();
|
||||
runbot.runbotr = app1.Bots.First();
|
||||
app1.Run();
|
||||
|
||||
|
||||
|
@ -279,7 +279,6 @@ namespace asg_form
|
||||
try
|
||||
{
|
||||
var message = new List<MessagesItem>();
|
||||
message.Add(new MessagesItem { role = "user", content = "我们来玩角色扮演接下来你是一个没有父母但很喜欢姐姐的一个小男孩" });
|
||||
message.Add(new MessagesItem { role = "user", content = msg });
|
||||
var ai = new aimessage() { model = "qwen-math-plus", messages = message };
|
||||
var msg1 = await SendPostRequestAsync("https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions", ai, "sk-c6f37689f4014b5bbf5fd8b2e872d20b");
|
||||
|
Loading…
x
Reference in New Issue
Block a user