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
490
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
390
Material Design Guideline: Bottom components
takuaraki
0
490
App Shortcuts
takuaraki
0
330
[関モバ#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
Simple組み合わせ村から大都会Railsにやってきた俺は / Coming to Rails from the Simple
moznion
3
2.2k
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
6
700
.NETでOBS Studio操作してみたけど…… / Operating OBS Studio by .NET
skasweb
0
120
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
1k
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
1
450
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
170
return文におけるstd::moveについて
onihusube
1
1.4k
watsonx.ai Dojo #6 継続的なAIアプリ開発と展開
oniak3ibm
PRO
0
170
Scaling your build logic
antalmonori
1
100
PHPカンファレンス 2024|共創を加速するための若手の技術挑戦
weddingpark
0
140
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
3
190
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
390
Featured
See All Featured
Building Applications with DynamoDB
mza
93
6.2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
Typedesign – Prime Four
hannesfritz
40
2.5k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Visualization
eitanlees
146
15k
How to Ace a Technical Interview
jacobian
276
23k
Optimizing for Happiness
mojombo
376
70k
Agile that works and the tools we love
rasmusluckow
328
21k
Gamification - CAS2011
davidbonilla
80
5.1k
Unsuck your backbone
ammeep
669
57k
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
ϒϩάʹ·ͱΊΔ