Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function sendToSlack(message) {
Logger.log('sendToSlack() debug start');
var url = 'webhook url';
var channel = '#calender';
var username = 'jojo-bot';
var icon_emoji = ':hand:';
var payload = {
'channel' : channel,
'text' : message,
'username' : username,
'icon_emoji' : icon_emoji
};
var params = {
'method' : 'post',
'payload' : JSON.stringify(payload)
};
UrlFetchApp.fetch(url, params);
Logger.log('sendToSlack() debug end');
}
function showStatus() {
Logger.log('showStatus() debug start');
var sheet = SpreadsheetApp.getActiveSheet();
var lastRow = sheet.getLastRow();
var i;
for (i = 2; i <= lastRow; i++) {
var dateCell = sheet.getRange(i, 2); // B列
var contentCell = sheet.getRange(i, 3); // C列
var date = dateCell.getValue();
var content = contentCell.getValue();
var formattedDate = Utilities.formatDate(date, 'Asia/Tokyo', 'MM-dd');
var displayDate = Utilities.formatDate(date, 'Asia/Tokyo', 'yyyy年M月d日');
var today = new Date();
var formattedToday = Utilities.formatDate(today, 'Asia/Tokyo', 'MM-dd');
var message = '' + displayDate + '】= ' + content;
if (formattedDate == formattedToday) {
sendToSlack(message);
};
};
Logger.log('showStatus() debug end');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.