Skip to content

Commit

Permalink
fix(plugins/qqstatplugin/): #计数;测试通过
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyungent committed Jan 24, 2023
1 parent 8f7c4a2 commit b4f4ed0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
12 changes: 12 additions & 0 deletions plugins/QQStatPlugin/DbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,17 @@ public static List<Message> QueryAllMessage()
}
}

public async static Task<long> Count()
{
using (IDbConnection con = new SQLiteConnection(ConnStr))
{
con.Open();

string sql = "SELECT COUNT(*) FROM Message;";

return await con.QueryFirstAsync<long>(sql);
}
}

}
}
6 changes: 3 additions & 3 deletions plugins/QQStatPlugin/QQStatPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ public void OnFriendMessage((Bot s, FriendMessageEvent e) obj, string message, u
{
try
{
var messages = DbContext.QueryAllMessage();
obj.s.SendFriendMessage(friendUin, $"共收集 Message {(messages?.Count.ToString() ?? "0")} 条");
long count = DbContext.Count().Result;
obj.s.SendFriendMessage(friendUin, $"共收集 Message {count} 条");
}
catch (Exception ex)
{
Console.WriteLine("查询 Message 出错");
Console.WriteLine("查询 Message 条数 出错");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/QQStatPlugin/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"DisplayName": "QQ消息统计分析",
"Description": "QQ消息等数据收集, 分析",
"Author": "yiyun",
"Version": "1.0.0",
"Version": "1.0.1",
"SupportedVersions": [ "0.0.1" ]
}
4 changes: 2 additions & 2 deletions plugins/QQStatPlugin/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"AdminQQ": "",
"AdminGroups": [ "", "" ],
"ChartGroups": [ "", "" ],
"BaseUrl": "",
"ScreenshotUrl": "https://webscreenshot-yiyun.herokuapp.com/?windowWidth=1080&forceWait=5&url="
"BaseUrl": "https://qqbothub.moeci.com",
"ScreenshotUrl": "https://webstack-screenshot.vercel.app/?viewport=1920x1080&fullPage=true&url="
}

0 comments on commit b4f4ed0

Please sign in to comment.