DeepLearning101 commited on
Commit
d4d6acc
·
verified ·
1 Parent(s): d5bc259

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -99,10 +99,22 @@ def handle_booking(name, tel, email, date_str, time, pax, remarks, line_id):
99
  try:
100
  supabase.table("bookings").insert(data).execute()
101
 
102
- # D. 發送 LINE Notify 給老闆
103
  if LINE_ACCESS_TOKEN and LINE_ADMIN_ID:
104
  src = "🟢 LINE用戶" if line_id else "⚪ 訪客"
105
- msg = f"🔥 新訂位 ({src})\n{name} / {tel}\n{date_str} {time} ({pax}人)"
 
 
 
 
 
 
 
 
 
 
 
 
106
  requests.post("https://api.line.me/v2/bot/message/push", headers={"Authorization": f"Bearer {LINE_ACCESS_TOKEN}", "Content-Type": "application/json"}, json={"to": LINE_ADMIN_ID, "messages": [{"type": "text", "text": msg}]})
107
 
108
  return """<div style='text-align: center; color: #fff; padding: 20px; border: 1px solid #d4af37; border-radius: 8px; background: #222;'><h2 style='color: #d4af37; margin: 0;'>Request Received</h2><p style='margin: 10px 0;'>🥂 預約申請已提交</p><p style='font-size: 0.9em; color: #aaa;'>請留意 Email 確認信。</p></div>"""
 
99
  try:
100
  supabase.table("bookings").insert(data).execute()
101
 
102
+ # D. 發送 LINE Notify 給老闆 (⚠️ 這裡修改了格式)
103
  if LINE_ACCESS_TOKEN and LINE_ADMIN_ID:
104
  src = "🟢 LINE用戶" if line_id else "⚪ 訪客"
105
+ # 處理備註:如果是空字串顯示 ""
106
+ note = remarks if remarks else "無"
107
+
108
+ # 👇 新的漂亮格式 👇
109
+ msg = (
110
+ f"🔥 新訂位 ({src})\n"
111
+ f"姓名:{name}\n"
112
+ f"電話:{tel}\n"
113
+ f"日期:{date_str}\n"
114
+ f"時間:{time}\n"
115
+ f"人數:{pax}人\n"
116
+ f"備註:{note}"
117
+ )
118
  requests.post("https://api.line.me/v2/bot/message/push", headers={"Authorization": f"Bearer {LINE_ACCESS_TOKEN}", "Content-Type": "application/json"}, json={"to": LINE_ADMIN_ID, "messages": [{"type": "text", "text": msg}]})
119
 
120
  return """<div style='text-align: center; color: #fff; padding: 20px; border: 1px solid #d4af37; border-radius: 8px; background: #222;'><h2 style='color: #d4af37; margin: 0;'>Request Received</h2><p style='margin: 10px 0;'>🥂 預約申請已提交</p><p style='font-size: 0.9em; color: #aaa;'>請留意 Email 確認信。</p></div>"""