From b4f4ed0a066ea89739aea5affc600f2f777740ca Mon Sep 17 00:00:00 2001 From: yiyun Date: Tue, 24 Jan 2023 13:49:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(plugins/qqstatplugin/):=20#=E8=AE=A1?= =?UTF-8?q?=E6=95=B0;=E6=B5=8B=E8=AF=95=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/QQStatPlugin/DbContext.cs | 12 ++++++++++++ plugins/QQStatPlugin/QQStatPlugin.cs | 6 +++--- plugins/QQStatPlugin/info.json | 2 +- plugins/QQStatPlugin/settings.json | 4 ++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/plugins/QQStatPlugin/DbContext.cs b/plugins/QQStatPlugin/DbContext.cs index a3a7811ba..c84abbb9c 100644 --- a/plugins/QQStatPlugin/DbContext.cs +++ b/plugins/QQStatPlugin/DbContext.cs @@ -57,5 +57,17 @@ public static List QueryAllMessage() } } + public async static Task Count() + { + using (IDbConnection con = new SQLiteConnection(ConnStr)) + { + con.Open(); + + string sql = "SELECT COUNT(*) FROM Message;"; + + return await con.QueryFirstAsync(sql); + } + } + } } diff --git a/plugins/QQStatPlugin/QQStatPlugin.cs b/plugins/QQStatPlugin/QQStatPlugin.cs index a3085d960..a89aab953 100644 --- a/plugins/QQStatPlugin/QQStatPlugin.cs +++ b/plugins/QQStatPlugin/QQStatPlugin.cs @@ -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 条数 出错"); } } } diff --git a/plugins/QQStatPlugin/info.json b/plugins/QQStatPlugin/info.json index f13afebe3..da2c46e7c 100644 --- a/plugins/QQStatPlugin/info.json +++ b/plugins/QQStatPlugin/info.json @@ -3,6 +3,6 @@ "DisplayName": "QQ消息统计分析", "Description": "QQ消息等数据收集, 分析", "Author": "yiyun", - "Version": "1.0.0", + "Version": "1.0.1", "SupportedVersions": [ "0.0.1" ] } \ No newline at end of file diff --git a/plugins/QQStatPlugin/settings.json b/plugins/QQStatPlugin/settings.json index 9e129e578..2dba452e8 100644 --- a/plugins/QQStatPlugin/settings.json +++ b/plugins/QQStatPlugin/settings.json @@ -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=" } \ No newline at end of file