Created
May 29, 2021 07:33
-
-
Save wendeehsu/9f53affcc45faa1171caf92dc33a86f4 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
function replyMsg(userId, replyToken, userMsg) { | |
var msg = ""; | |
if (userMsg == "打卡提醒") { // "Remind me to punch." | |
if (checkUser(userId) == -1) { | |
addUser(userId); | |
msg = "那我以後9:00和18:00會提醒你喔~"; // "I'll remind you at 9:00 and 18:00 in the future." | |
} else { | |
msg = "你已經在提醒名單中了:)"; // "You're already on the remind list." | |
} | |
} else if (userMsg == "取消提醒") { // "Stop reminding me." | |
var index = checkUser(userId); | |
if (index == -1) { | |
msg = "你本來就不在提醒名單中喔!"; // "You're not on the remind list." | |
} else { | |
deleteRowAt(index); | |
msg = "好,以後自己記得打卡喔:)"; // "OK. Please remember to punch on your own." | |
} | |
} | |
console.log(msg); | |
var opt = { | |
'headers': { | |
'Content-Type': 'application/json; charset=UTF-8', | |
'Authorization': 'Bearer ' + channelToken, | |
}, | |
'method': 'post', | |
'payload': JSON.stringify({ | |
'replyToken': replyToken, | |
'messages': [{'type': 'text', 'text': msg}] | |
}) | |
}; | |
UrlFetchApp.fetch('https://api.line.me/v2/bot/message/reply', opt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment