Skip to content

Commit

Permalink
fix 修正/myinfo无法使用的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed Nov 20, 2022
1 parent 4579d8f commit 2460e9f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions XinjingdailyBot/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Reflection;

[assembly: CLSCompliant(false)]
[assembly: AssemblyVersion("1.0.11.701")]
[assembly: AssemblyFileVersion("1.0.11.701")]
[assembly: AssemblyVersion("1.0.11.710")]
[assembly: AssemblyFileVersion("1.0.11.710")]

[assembly: AssemblyCopyright("Copyright @ 2022 Chr_")]
[assembly: AssemblyProduct("XinjingDaily Bot")]
Expand Down
41 changes: 22 additions & 19 deletions XinjingdailyBot/Handlers/Messages/Commands/NormalCmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,47 +80,50 @@ internal static async Task ResponseMyInfo(ITelegramBotClient botClient, Users db

StringBuilder sb = new();

sb.AppendLine($"-- 基础信息 --");
sb.AppendLine("-- 基础信息 --");
sb.AppendLine($"用户名: <code>{userNick}</code>");
sb.AppendLine($"用户ID: <code>{dbUser.UserID}</code>");
sb.AppendLine($"用户组: <code>{group}</code>");
sb.AppendLine($"等级: <code>{level}</code>");
sb.AppendLine($"投稿数量: <code>{totalPost}</code>");
sb.AppendLine($"通过率: <code>{(100.0 * dbUser.AcceptCount / totalPost).ToString("0.00")}%</code>");
sb.AppendLine($"投稿通过率: <code>{(100.0 * dbUser.AcceptCount / totalPost).ToString("0.00")}%</code>");
sb.AppendLine($"通过数量: <code>{dbUser.AcceptCount}</code>");
sb.AppendLine($"拒绝数量: <code>{dbUser.RejetCount}</code>");
sb.AppendLine($"审核数量: <code>{dbUser.ReviewCount}</code>");
sb.AppendLine($"-- 用户排名 --");
sb.AppendLine();
sb.AppendLine("-- 用户排名 --");

DateTime now = DateTime.Now;
DateTime prev30Days = now.AddDays(-30).AddHours(-now.Hour).AddMinutes(-now.Minute).AddSeconds(-now.Second);

if (dbUser.AcceptCount > 10 && dbUser.GroupID == 1)
if (dbUser.GroupID == 1)
{
int activeUser = await DB.Queryable<Users>().Where(x => !x.IsBan && !x.IsBot && x.ModifyAt >= prev30Days).CountAsync();
int acceptCountRank = await DB.Queryable<Users>().Where(x => !x.IsBan && !x.IsBot && x.GroupID == 1 && x.AcceptCount > dbUser.AcceptCount && x.ModifyAt >= prev30Days).CountAsync() + 1;
if (dbUser.AcceptCount >= 1)
{
const int miniumPost = 10;

double ratio = 1.0 * dbUser.AcceptCount / dbUser.PostCount;
int acceptCountRank = await DB.Queryable<Users>().Where(x => !x.IsBan && !x.IsBot && x.GroupID == 1 && x.AcceptCount > dbUser.AcceptCount && x.ModifyAt >= prev30Days).CountAsync() + 1;

int acceptRatioRank = await DB.Queryable<Users>().Where(x => !x.IsBan && !x.IsBot && x.GroupID == 1 && x.AcceptCount > 10 && x.ModifyAt >= prev30Days)
.Select(y => new { Ratio = y.AcceptCount / y.PostCount }).Where(x => x.Ratio > ratio).CountAsync() + 1;
double ratio = 1.0 * dbUser.AcceptCount / dbUser.PostCount;
int acceptRatioRank = await DB.Queryable<Users>().Where(x => !x.IsBan && !x.IsBot && x.GroupID == 1 && x.AcceptCount > miniumPost && x.ModifyAt >= prev30Days)
.Select(y => 100.0 * y.AcceptCount / y.PostCount).Where(x => x > ratio).CountAsync() + 1;

sb.AppendLine($"通过数量: <code>{acceptCountRank}</code>");
sb.AppendLine($"通过率: <code>{acceptRatioRank}</code>");
sb.AppendLine($"活跃用户: <code>{activeUser}</code>");
}
else
{
if (dbUser.GroupID != 1)
{
sb.AppendLine($"管理员不参与用户排名");
sb.AppendLine($"可以使用命令 /userrank 查看管理员排名");
sb.AppendLine($"通过数排名: <code>{acceptCountRank}</code>");
sb.AppendLine($"通过率排名: <code>{acceptRatioRank}</code>");
}
else
{
sb.AppendLine("稿件数量太少, 未进入排行榜");
}
}
else
{
int activeUser = await DB.Queryable<Users>().Where(x => !x.IsBan && !x.IsBot && x.ModifyAt >= prev30Days).CountAsync();
sb.AppendLine($"活跃用户数: <code>{activeUser}</code>");

sb.AppendLine($"管理员不参与用户排名");
sb.AppendLine($"可以使用命令 /userrank 查看总排名");
}

await botClient.SendCommandReply(sb.ToString(), message, parsemode: ParseMode.Html);
}
Expand Down

0 comments on commit 2460e9f

Please sign in to comment.