Created
March 28, 2018 12:38
-
-
Save sorashido/a7477183ea52ea873dc90969629d7fa9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sendMessage(text){ | |
var postUrl = 'URL'; | |
var username = 'bot'; | |
var icon = ':hatched_chick:'; | |
var message = text; | |
var jsonData = { | |
"username" : username, | |
"icon_emoji": icon, | |
"text" : message | |
}; | |
var payload = JSON.stringify(jsonData); | |
var options = | |
{ | |
"method" : "post", | |
"contentType" : "application/json", | |
"payload" : payload | |
}; | |
UrlFetchApp.fetch(postUrl, options); | |
} | |
function compareDate(date1,date2){ | |
if(date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate()){ | |
return true; | |
}else{ | |
return false; | |
} | |
} | |
function myFunction(){ | |
var spreadSheet = SpreadsheetApp.openByUrl('url'); | |
var sheet = spreadSheet.getSheets()[0]; | |
var date_array = sheet.getRange(2, 2, 51).getValues(); | |
var name_array = sheet.getRange(2, 3, 51).getValues(); | |
var today = new Date(); | |
date_array.some(function(array, i, date_array){ | |
if(compareDate(array[0], today)==true && name_array[i][0].length > 0){ | |
var date = today.getFullYear() + '/' + (today.getMonth() + 1) + '/' + today.getDate() | |
var message = date + 'の係は' + name_array[i][0] + 'さんだよ'; | |
sendMessage(message); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment