From 6da4db84337aca8a995ac669cd40633f33423bed Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 17 Jun 2021 16:40:07 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20groupcloud=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=86=E6=9E=90=E6=B6=88=E6=81=AF=E6=95=B0=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- groupword.py | 16 ++++++++++------ list.json | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/groupword.py b/groupword.py index 242187b..8037f5f 100644 --- a/groupword.py +++ b/groupword.py @@ -51,7 +51,7 @@ async def group_word(context): words = defaultdict(int) count = 0 try: - async for msg in context.client.iter_messages(context.chat, limit=300): + async for msg in context.client.iter_messages(context.chat, limit=500): if msg.id == context.id: continue if msg.text: @@ -69,12 +69,16 @@ async def group_word(context): return except: return - image = WordCloud(font_path="plugins/groupword/wqy-microhei.ttc", width=800, height=400).generate_from_frequencies( - words).to_image() - stream = BytesIO() - image.save(stream, 'PNG') try: - await context.client.send_message(context.chat, '', file=stream.getvalue()) + image = WordCloud(font_path="plugins/groupword/wqy-microhei.ttc", width=800, height=400).generate_from_frequencies( + words).to_image() + stream = BytesIO() + image.save(stream, 'PNG') + except: + await context.edit('词云生成失败。') + return + try: + await context.client.send_message(context.chat, f'对最近的 {count} 条消息进行了分析。', file=stream.getvalue()) await context.delete() except: return diff --git a/list.json b/list.json index 859fb74..800cfb4 100644 --- a/list.json +++ b/list.json @@ -512,7 +512,7 @@ }, { "name": "groupword", - "version": "1.02", + "version": "1.03", "section": "chat", "maintainer": "xtaodada", "size": "3.32 kb",