|
15 | 15 | ) |
16 | 16 | from nonebot_plugin_session import EventSession, SessionIdType |
17 | 17 |
|
18 | | -from ..plot import plot_duration_counts, plot_key_and_duration_counts |
| 18 | +from ..manager import meme_manager |
| 19 | +from ..plot import plot_duration_counts, plot_meme_and_duration_counts |
19 | 20 | from ..recorder import get_meme_generation_records, get_meme_generation_times |
20 | 21 | from ..utils import add_timezone |
21 | 22 | from .utils import find_meme |
@@ -171,6 +172,9 @@ async def _( |
171 | 172 | meme_records = await get_meme_generation_records( |
172 | 173 | session, id_type, time_start=start |
173 | 174 | ) |
| 175 | + meme_records = [ |
| 176 | + record for record in meme_records if meme_manager.get_meme(record.meme_key) |
| 177 | + ] |
174 | 178 | meme_times = [record.time for record in meme_records] |
175 | 179 | meme_keys = [record.meme_key for record in meme_records] |
176 | 180 |
|
@@ -209,11 +213,17 @@ def fmt_time(time: datetime) -> str: |
209 | 213 |
|
210 | 214 | if meme: |
211 | 215 | title = ( |
212 | | - f"表情“{meme.key}”{humanized}调用统计" |
| 216 | + f"表情“{'/'.join(meme.keywords)}”{humanized}调用统计" |
213 | 217 | f"(总调用次数为 {key_counts.get(meme.key, 0)})" |
214 | 218 | ) |
215 | 219 | output = await plot_duration_counts(duration_counts, title) |
216 | 220 | else: |
217 | 221 | title = f"{humanized}表情调用统计(总调用次数为 {sum(key_counts.values())})" |
218 | | - output = await plot_key_and_duration_counts(key_counts, duration_counts, title) |
| 222 | + meme_counts: dict[str, int] = {} |
| 223 | + for key, count in key_counts.items(): |
| 224 | + if meme := meme_manager.get_meme(key): |
| 225 | + meme_counts["/".join(meme.keywords)] = count |
| 226 | + output = await plot_meme_and_duration_counts( |
| 227 | + meme_counts, duration_counts, title |
| 228 | + ) |
219 | 229 | await UniMessage.image(raw=output).send() |
0 commit comments