-
-
Save jschang19/91d47973e2f85e03ef9097e055c3c264 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 「加一」報名關鍵字 | |
if (userMessage == "+1" | userMessage == "加一" | userMessage == "+1") { | |
// 判斷時間是否為報名時段內,參考文章第三步驟說明 | |
if (current_hour >= 0 & current_hour <= 19 | current_hour >= 21) { | |
// 若目前報名人數小於人數上限( 40 人 ),將使用者的名字記錄到試算表裡 | |
if (current_list_row < maxium_member) { | |
reserve_list.getRange(current_list_row + 1, 1).setValue(reserve_name); | |
current_list_row = reserve_list.getLastRow(); | |
// 報名成功回傳成功訊息 | |
reply_message = [{ | |
"type": "text", | |
"text": reserve_name + "成功預約 🙆,是第 " + current_list_row + " 位。" + "還有 " + (maxium_member - current_list_row) + " 位名額" | |
}] | |
} | |
// 設有 3 位候補名額,若報名人數大於 40 人,將第 41 - 43 行的資料設為候補名額 | |
else if (current_list_row >= maxium_member & current_list_row < (waiting_member + maxium_member)) { | |
reserve_name = "候補:" + reserve_name; // 加上「候補」兩字作為標籤 | |
reserve_list.getRange(current_list_row + 1, 1).setValue(reserve_name); | |
// 回傳訊息,告知為候補名額 | |
reply_message = [{ | |
"type": "text", | |
"text": "超過 40 人。" + reserve_name + " 為候補預約" | |
}] | |
} | |
// 若報名名單與候補名額已滿( 大於 43 人 ),不再紀錄到試算表,並回傳已額滿訊息 | |
else { | |
reply_message = [{ | |
"type": "text", | |
"text": "⚠️ 報名額滿!已達 " + maxium_member + "人" | |
}] | |
} | |
} | |
// 非預約時間的提示訊息回覆 | |
else { | |
reply_message = [{ | |
"type": "text", | |
"text": "現在不是報名時間喔 ~ ,請在 00:00 - 19:00 預約" | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment