Skip to content

Instantly share code, notes, and snippets.

@sugiii8
Last active September 10, 2019 02:30
Show Gist options
  • Save sugiii8/8f64b52b45dc37f0a48a37e895c0e976 to your computer and use it in GitHub Desktop.
Save sugiii8/8f64b52b45dc37f0a48a37e895c0e976 to your computer and use it in GitHub Desktop.
シートをシャッフルしてSlack通知するgas
function getLastRowWithValue() {
const sheet = SpreadsheetApp.getActiveSheet();
const names = sheet.getRange('A:A').getValues().filter(String);
shuffle(names);
const message = names.join('\n')
slack(message)
}
function shuffle(array) {
for(var i = array.length - 1; i > 0; i--){
var r = Math.floor(Math.random() * (i + 1));
var tmp = array[i];
array[i] = array[r];
array[r] = tmp;
}
}
function slack(message) {
var slackWebhookURL = 'WEB HOOK URL IS HERE'
UrlFetchApp.fetch(slackWebhookURL, {
method: 'post',
payload: JSON.stringify({
text: 'SOMETHING MESSAGE\n' + (orders || '')
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment