-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathline_messages.py
More file actions
117 lines (108 loc) · 3.82 KB
/
Copy pathline_messages.py
File metadata and controls
117 lines (108 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from linebot.models import (
FlexSendMessage,
CarouselContainer,
BubbleContainer,
TextSendMessage,
BoxComponent,
ImageComponent,
TextComponent,
ButtonComponent
)
from config import IMAGE_URLS
import json
def create_shop_message():
"""Create the shop carousel Flex Message."""
# JSONファイルからデザインデータを読み込む
with open('flex_templates.json', 'r', encoding='utf-8') as f:
shop_carousel = json.load(f)
return FlexSendMessage(alt_text="月面コンビニ", contents=shop_carousel)
def create_member_card(user_data):
"""Create the member card Flex Message based on user data."""
my_items = user_data.get("items", [])
current_look = user_data.get("current_look", "normal")
current_streak = user_data.get("current_streak", 0)
carrot_count = user_data.get("carrot_count", 0)
# Determine display image and status text
display_image = IMAGE_URLS["normal"]
status_text = "ノーマル"
if current_look == "sunglasses":
display_image = IMAGE_URLS["sunglasses"]
status_text = "サングラス装着中 😎"
elif current_look == "pink":
display_image = IMAGE_URLS["pink"]
status_text = "ピンクに変身中 🎀"
# Check for substitute doll
doll_status = "あり 🧸" if "substitute_doll" in my_items else "なし"
status_card = {
"type": "bubble",
"hero": {
"type": "image",
"url": display_image,
"size": "full",
"aspectRatio": "1:1",
"aspectMode": "cover",
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "月うさぎ会員証 🌕",
"weight": "bold",
"size": "xl",
},
{"type": "separator", "margin": "md"},
{
"type": "box",
"layout": "vertical",
"margin": "md",
"spacing": "sm",
"contents": [
{
"type": "text",
"text": f"🥕 所持人参: {carrot_count} 本",
"size": "sm",
"color": "#666666",
},
{
"type": "text",
"text": f"🔥 連続記録: {current_streak} 日",
"size": "sm",
"color": "#666666",
},
{
"type": "text",
"text": f"🧸 身代わり人形: {doll_status}",
"size": "sm",
"color": "#666666",
},
{
"type": "text",
"text": f"状態: {status_text}",
"size": "sm",
"color": "#aaaaaa",
"margin": "sm",
},
],
},
],
},
"footer": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "button",
"style": "primary",
"color": "#FF9933",
"action": {
"type": "message",
"label": "ショップを見る",
"text": "ショップ",
},
}
],
},
}
return FlexSendMessage(alt_text="会員証", contents=status_card)