️ groupcloud 增加分析消息数提示。

This commit is contained in:
xtaodada 2021-06-17 16:40:07 +08:00
parent ba535f8e31
commit 6da4db8433
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 11 additions and 7 deletions

View File

@ -51,7 +51,7 @@ async def group_word(context):
words = defaultdict(int) words = defaultdict(int)
count = 0 count = 0
try: 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: if msg.id == context.id:
continue continue
if msg.text: if msg.text:
@ -69,12 +69,16 @@ async def group_word(context):
return return
except: except:
return 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: 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() await context.delete()
except: except:
return return

View File

@ -512,7 +512,7 @@
}, },
{ {
"name": "groupword", "name": "groupword",
"version": "1.02", "version": "1.03",
"section": "chat", "section": "chat",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "3.32 kb", "size": "3.32 kb",