Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GASでSlackBot
Search
takuaraki
August 22, 2018
Programming
1
480
GASでSlackBot
Google App Scriptsを利用して勤怠管理のSlackBotを作った話です。
takuaraki
August 22, 2018
Tweet
Share
More Decks by takuaraki
See All by takuaraki
2021/02/03 発覚の COCOA Android版 不具合について
takuaraki
0
47
Androidアプリ内課金のテスト
takuaraki
0
420
Material Design Guideline: Dialogs, Dividers
takuaraki
0
380
Material Design Guideline: Bottom components
takuaraki
0
480
App Shortcuts
takuaraki
0
320
[関モバ#18] SQLBrite&SQLDelight
takuaraki
0
420
A/B testing GTM&GA vs Firebase
takuaraki
1
2.9k
【関モバ#12】Google Tag ManagerでモバイルアプリのABテストをする
takuaraki
1
610
Other Decks in Programming
See All in Programming
Go の GC の不得意な部分を克服したい
taiyow
3
780
CSC305 Lecture 26
javiergs
PRO
0
140
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
770
テスト自動化失敗から再挑戦しチームにオーナーシップを委譲した話/STAC2024 macho
ma_cho29
1
1.3k
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
ドメインイベント増えすぎ問題
h0r15h0
2
300
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
330
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
GraphQLとの向き合い方2022年版
quramy
44
13k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
YesSQL, Process and Tooling at Scale
rocio
169
14k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Transcript
("4Ͱ4MBDL#PU ߥ !BSB@UBDL
"CPVU.F w ߥ !BSB@UBDL w '63:6$PSQ w "OESPJEͬͯ·͢ w
,PUMJOॻ͍ͯ·͢
࠷ۙͷۈଵཧ 4MBDLͰͬͯ·͢
͜Μͳײ͡
4MBDLͰͷۈଵཧ w ϝʔϧΑΓָͰྑ͍ײ͡ w ࠓɺ୭͕ٳΉͷ͔ḪΒͳ͍ͱ͔Βͳ͍ w ேྱͰಉ͡νʔϜͷਓ͕Θ͟Θ͟ใࠂͯͨ͠ ˠࠓɺٳΉਓ͕4MBDLͰ௨͞ΕͨΒ͍͍ͳʔ
,JOUBJ#PU࡞Γ·ͨ͠ OBNF OBNF OBNF OBNF
,JOUBJ#PU w 4MBDLͰͷɺΈΜͳͷۈଵൃݴΛه w ຖேɺͦͷͷରऀΛूܭ w ໊લೖྗຊจΛ·ͱΊͯߘ OBNF OBNF OBNF
OBNF
ͬͨͷ w 4MBDL0VUHPJOH8FC)PPLT w (PPHMF"QQT4DSJQU ("4 w (PPHMFεϓϨουγʔτ
0VUHPJOH8FC)PPLT w 4MBDLͷಛఆͷจࣈΛؚΉߘʹԠ͢Δ w ࢦఆͨ͠63-ʹ1045ϦΫΤετΛ͛Δ w ϦΫΤετύϥϝʔλ͕ߘϢʔβʔ໊ɺ ߘϝοηʔδͳͲΛؚΉ
(PPHMF"QQT4DSJQU w +BWBTDSJQUޓͷεΫϦϓτݴޠ w (PPHMFυΩϡϝϯτεϓϨουγʔτͳͲͷ (PPHMF"QQTΛૢ࡞Ͱ͖Δ w ࣌ؒ)551ϦΫΤετΛτϦΨʔʹͯ͠ ಈ͔͢͜ͱ͕Ͱ͖Δ
γεςϜߏ ("4 ۈଵه (PPHMF 4QSFBE 4IFFU ("4 ۈଵूܭ 0VUHPJOH 8FC)PPLT
ۈଵೖྗ ࠓͷۈଵʁ ूܭ݁Ռදࣔ 1045 ϦΫΤετ σʔλΛ ه σʔλΛ औಘ 1045 ϦΫΤετ ूܭ݁ՌΛ 4MBDLʹߘ
γεςϜߏ ("4 ۈଵه (PPHMF 4QSFBE 4IFFU ("4 ۈଵूܭ 0VUHPJOH 8FC)PPLT
ۈଵೖྗ ࠓͷۈଵʁ ूܭ݁Ռදࣔ 1045 ϦΫΤετ σʔλΛ ه σʔλΛ औಘ 1045 ϦΫΤετ ूܭ݁ՌΛ 4MBDLʹߘ
ۈଵهɿ4MBDL w ۈଵൃݴશһ΄΅ಉ͡ϑΥʔϚοτͩͬͨ ྫ ʲશٳʳʢਫʣࢲ༻ͷͨΊ w ʮʲʯΛτϦΨʔʹ0VUHPJOH8FC)PPLTͰ ه༻ͷ("4ʹ1045ϦΫΤετΛૹ৴ w 1045ϦΫΤετʹߘऀͱຊจ͕ࡌ͍ͬͯΔ
ۈଵهɿ("4 w 4MBDL͔Β1045ϦΫΤετΛड͚Δ w ຊจ͔Βਖ਼نදݱͰΛநग़͢Δ ͜ͷΛɺٳΉͱͯ͠ѻ͏ ྫ ʲશٳʳʢਫʣࢲ༻ͷͨΊˠ w ٳΉɺߘऀɺຊจΛεϓϨουγʔτʹه
ۈଵهɿ("4 function doPost(e) { // ରͷΛநग़ var pattern = /(?:\d{4}\/|)([1-9]|0[1-9]|1[0-2])\/([1-9]|0[1-9]|[12][0-9]|3[01])/;
var matchResult = e.parameter.text.match(pattern); var date = new Date().getFullYear() + "/" + matchResult[1] + "/" + matchResult[2]; // εϓϨουγʔτʹɺ໊લɺຊจΛه var sheet = getCurrentYearSpreadsheet().getSheets()[0]; var kintaiValues = sheet.getSheetValues(1, 1, maxRowCount, 3); var newLineRow = -1; for (var row = 0; row < 10000; row++) { var dateCell = kintaiValues[row][0]; if (dateCell == "") { newLineRow = row + 1; break; } } arrData = [ [date, e.parameter.user_name, e.parameter.text] ]; sheet.getRange(newLineRow, 1, 1, 3).setValues(arrData); }
%FNP ʮʲશٳʳʢਫʣࢲ༻ͷͨΊʯͱଧͬͯɺ εϓϨουγʔτʹՃ͞ΕΔͷΛݟͯΈΔ
γεςϜߏ ("4 ۈଵه (PPHMF 4QSFBE 4IFFU ("4 ۈଵूܭ 0VUHPJOH 8FC)PPLT
ۈଵೖྗ ࠓͷۈଵʁ ूܭ݁Ռදࣔ 1045 ϦΫΤετ σʔλΛ ه σʔλΛ औಘ 1045 ϦΫΤετ ूܭ݁ՌΛ 4MBDLʹߘ
γεςϜߏ ("4 ۈଵه (PPHMF 4QSFBE 4IFFU ("4 ۈଵूܭ 0VUHPJOH 8FC)PPLT
ۈଵೖྗ ࠓͷۈଵʁ ूܭ݁Ռදࣔ 1045 ϦΫΤετ σʔλΛ ه σʔλΛ औಘ 1045 ϦΫΤετ ूܭ݁ՌΛ 4MBDLʹߘ
ۈଵूܭɿ4MBDL w ࠓͷۈଵʁͱ͍͏4MBDLϦϚΠϯμʔΛ ࢝ۀͷલʹηοτ SFNJOE,JOUBJUPࠓͷۈଵʁBUFWFSZXFFLEBZ w ࠓͷۈଵʁΛτϦΨʔʹ0VUHPJOH8FC)PPL Ͱूܭ༻ͷ("4ʹ1045ϦΫΤετ
ۈଵूܭɿ("4 w ۈଵهͷεϓϨουγʔτΛಡΈࠐΉ σʔλɺߘऀɺຊจ w ݱࡏͱಉ͡ͷσʔλ͚ͩநग़ w நग़ͨ͠σʔλ͔Β4MBDLߘ༻ͷจΛ࡞ͯ͠ 4MBDLʹߘ͢Δ
ۈଵूܭɿ("4 function doPost(e) { var now = new Date(); var
slackMessage = "```\n”; var sheet = getCurrentYearSpreadsheet().getSheets()[0]; var kintaiValues = sheet.getSheetValues(1, 1, maxRowCount, 3); for (var row = 1; row < 10000; row++) { var date = kintaiValues[row][0]; if (date == "") { break; } // ݱࡏͱಉ͡σʔλ͚ͩநग़ͯ͠ɺߘ༻ϝοηʔδʹՃ if (date.getFullYear() == now.getFullYear() && date.getMonth() == now.getMonth() && date.getDate() == now.getDate()) { var name = kintaiValues[row][1]; var text = kintaiValues[row][2]; slackMessage += name + " " + text + "\n"; } } slackMessage += "```"; sendToSlack(slackMessage); }
%FNP ʮࠓͷۈଵʁʯͱଧͬͯɺ ूܭ݁Ռ͕ߘ͞ΕΔͷΛݟͯΈΔ
࡞ͬͨײ w (PPHMFυϥΠϒ্Ͱ݁ͨ͠ͷͰָͩͬͨ w (PPHMF"QQT4DSJQU໘ന͍ɻ͍Ζ͍ΖͰ͖ͦ͏ w #PUՄѪ͍ɻ༊͞ΕΔ ࡞ͬͯΈ͍͔͕ͯʁ
ࠓޙΓ͍ͨ͜ͱ w ՄѪ໊͍લͱΞΠίϯΛ͚͍ͭͨ w ʹόάΔ͜ͱ͕Θ͔͍ͬͯΔͷͰͳΜͱ͔͢Δ w ΑΓ៉ྷͳϑΥʔϚοτͰूܭΛߘ͢Δ w औΓফ͠ػೳΛ͚ͭΔ w
ϒϩάʹ·ͱΊΔ