シートをシャッフルしてSlack通知するgas
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 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