-
-
Save bob2314/73fdfa004b5c96aead7062f781d731d5 to your computer and use it in GitHub Desktop.
GasでSlackbot、データを2つとって結合して出力
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 doPost(y) { | |
| var token = PropertiesService.getScriptProperties().getProperty("xoxp-123"); | |
| var name = "name"; | |
| var token = PropertiesService.getScriptProperties().getProperty('SLACK_ACCESS_TOKEN'); | |
| var app = SlackApp.create(token); | |
| var spreadsheet = SpreadsheetApp.openById('sheetID'); | |
| var sheet = spreadsheet.getSheetByName('シート1'); | |
| var range = sheet.getRange("シート1!C1").setFormula('=INDIRECT("シート1!A:A" & INT(RAND()*n+1))'); | |
| //A列内からランダムでC列1番セルに出力 | |
| var range2 = sheet.getRange("シート1!D1").setFormula('=INDIRECT("シート1!B:B" & INT(RAND()*n+1))'); | |
| //B列内からランダムでD列1番セルに出力 | |
| var message =sheet.getRange("シート1!C1").getValue()+sheet.getRange("シート1!D1").getValue(); | |
| //C1セルとD1セルの内容をつなげてbotの投稿として出力 | |
| return app.postMessage("#general", message, { | |
| username: name, | |
| icon_emoji: ':emojiname:' | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment