diff --git a/src/clover_sqlite/models/tarot.py b/src/clover_sqlite/models/tarot.py index df95d5a..f1ae376 100644 --- a/src/clover_sqlite/models/tarot.py +++ b/src/clover_sqlite/models/tarot.py @@ -127,10 +127,10 @@ class TarotExtractLog(Model): cards = [] deck = [] spread_config = { - 4: {"name":"三角牌阵","count": 3, "positions": ["过去", "现在", "未来"]}, - 5: {"name":"六芒星牌阵","count": 6, "positions": ["现状", "挑战", "建议", "根源", "希望", "结果"]}, - 6: {"name":"凯尔特十字牌阵","count": 10,"positions": ["核心", "阻碍", "过去", "现在", "未来", "潜在", "态度", "环境", "希望", "结果"]}, - 7: {"name":"恋人牌阵","count": 5, "positions": ["自我状态", "对方状态", "关系现状", "挑战", "未来"]} + 4: {"name":"三角牌阵","html_name":"A1CelticCross.html","count": 3, "positions": ["过去", "现在", "未来"]}, + 5: {"name":"六芒星牌阵","html_name":"A1Hexagram.html","count": 6, "positions": ["过去", "现在", "未来", "潜在", "外部", "结果"]}, + 6: {"name":"凯尔特十字牌阵","html_name":"","count": 10,"positions": ["核心", "阻碍", "过去", "现在", "未来", "潜在", "态度", "环境", "希望", "结果"]}, + 7: {"name":"恋人牌阵","html_name":"","count": 5, "positions": ["自我状态", "对方状态", "关系现状", "挑战", "未来"]} } deck = await MajorArcana.all() + await MinorArcana.all() # 防止重复抽牌 @@ -149,7 +149,8 @@ class TarotExtractLog(Model): "orientation": orientation, "position_meaning": spread_config[extract_type]["positions"][len(cards)] }) - file_path = temp_path + user_id + f"{spread_config[extract_type]['name']}{datetime.now().date()}.png" + file_path = temp_path + user_id + f"{spread_config[extract_type]['name']}{datetime.now().date()}.jpeg" + template_name = f"{spread_config[extract_type]['html_name']}" # 创建记录 log = await cls.create( user_id=user_id, @@ -163,13 +164,15 @@ class TarotExtractLog(Model): ) image_bytes = await template_to_pic( template_path = tarots_img_path, - template_name="A1CelticCross.html", + template_name = template_name, templates={"data": log.spread_data.get("cards")}, + quality=80, + type="jpeg", pages={ - "viewport": {"width": 980, "height": 900}, + "viewport": {"width": 1100, "height": 1200}, "base_url": f"file://{getcwd()}", }, - wait=2, + wait=10, ) with open(file_path, "wb") as file: file.write(image_bytes) diff --git a/src/plugins/fortune.py b/src/plugins/fortune.py index 142b0bb..ec9e3f9 100644 --- a/src/plugins/fortune.py +++ b/src/plugins/fortune.py @@ -40,12 +40,13 @@ tarot = on_command("今日塔罗", rule=to_me(), priority=10, block=True) async def get_tarot(message: MessageEvent): #extract_type : 1大阿尔克纳牌 2小阿尔克纳牌 3 混合牌组 4三角牌阵 5六芒星牌阵 6凯尔特十字牌阵 7恋人牌阵 value = message.get_plaintext().strip().split(" ") - if len(value) < 2 or len(value) > 2 or value[1] == "" or value[1] not in ["1","2","3","4"]: + if len(value) < 2 or len(value) > 2 or value[1] == "" or value[1] not in ["1","2","3","4","5"]: await tarot.finish("请输入正确的指令格式:/今日塔罗 + 数字(1-7) \n" "1 大阿尔克纳牌 \n" "2 小阿尔克纳牌 \n" "3 混合牌组 \n" - "4 三角牌阵 " + "4 三角牌阵 \n" + "5 六芒星牌阵 " ) result = await TarotExtractLog.tarotChoice(int(value[1]),message.get_user_id()) if result.extract_type in [1,2,3]: diff --git a/src/resources/image/tarot/TarotImages/1.jpg b/src/resources/image/tarot/TarotImages/1.jpg deleted file mode 100644 index 800efb1..0000000 Binary files a/src/resources/image/tarot/TarotImages/1.jpg and /dev/null differ diff --git a/src/resources/image/tarot/TarotImages/A1CelticCross.html b/src/resources/image/tarot/TarotImages/A1CelticCross.html index a1666ba..dadb42f 100644 --- a/src/resources/image/tarot/TarotImages/A1CelticCross.html +++ b/src/resources/image/tarot/TarotImages/A1CelticCross.html @@ -13,7 +13,6 @@ body { margin: 0; min-height: 100vh; - background: url('1.jpg') center/cover fixed; font-family: '华文楷体', serif; color: #f0e6d6; display: grid; @@ -54,7 +53,7 @@ } #present { - bottom: -180px; + bottom: -165px; left: 50%; transform: translateX(-50%); } @@ -96,6 +95,7 @@ padding: 0 10px; } +
diff --git a/src/resources/image/tarot/TarotImages/A1Hexagram.html b/src/resources/image/tarot/TarotImages/A1Hexagram.html new file mode 100644 index 0000000..03f5c6c --- /dev/null +++ b/src/resources/image/tarot/TarotImages/A1Hexagram.html @@ -0,0 +1,165 @@ + + + + + +{{data[1].meaning}}
+{{data[2].meaning}}
+{{data[4].meaning}}
+{{data[5].meaning}}
+{{data[0].meaning}}
+{{data[3].meaning}}
+