Skip to content

Instantly share code, notes, and snippets.

@wendeehsu
Created May 29, 2021 07:33
Show Gist options
  • Save wendeehsu/9f53affcc45faa1171caf92dc33a86f4 to your computer and use it in GitHub Desktop.
Save wendeehsu/9f53affcc45faa1171caf92dc33a86f4 to your computer and use it in GitHub Desktop.
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