diff --git a/README.md b/README.md index cb8b5401..a47d476c 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,7 @@ __Docker 最新版本由 [Sakuracio](https://github.com/Sakuracio) 提供__ * 修复私聊无法添加昵称 * 修复原神玩家查询层岩巨渊地下矿区没开时报错 * 修复 ```休息吧``` 无法阻断戳一戳 +* 当图库无图片时,戳一戳将略过发送图片 ### 2022/5/26 diff --git a/plugins/poke/__init__.py b/plugins/poke/__init__.py index 0f5b5f88..229a1699 100755 --- a/plugins/poke/__init__.py +++ b/plugins/poke/__init__.py @@ -62,12 +62,12 @@ async def _poke_event(event: PokeNotifyEvent): rst = "气死我了!" await poke_.finish(rst + random.choice(poke__reply), at_sender=True) rand = random.random() - if rand <= 0.3: - path = random.choice(["luoli", "meitu"]) + path = random.choice(["luoli", "meitu"]) + if rand <= 0.3 and len(os.listdir(IMAGE_PATH / "image_management" / path)) > 0: index = random.randint(0, len(os.listdir(IMAGE_PATH / "image_management" / path))) result = f"id:{index}" + image(f"{index}.jpg", "image_management/" + path) await poke_.send(result) - logger.info(f"USER {event.user_id} 戳了戳我 回复: {result} \n {result}") + logger.info(f"USER {event.user_id} 戳了戳我 回复: {result} {result}") elif 0.3 < rand < 0.6: voice = random.choice(os.listdir(RECORD_PATH / "dinggong")) result = record(voice, "dinggong")