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
410
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
410
A/B testing GTM&GA vs Firebase
takuaraki
1
2.9k
【関モバ#12】Google Tag ManagerでモバイルアプリのABテストをする
takuaraki
1
600
Other Decks in Programming
See All in Programming
Tuning GraphQL on Rails
pyama86
2
1.2k
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
170
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
430
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
790
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
2.5k
受け取る人から提供する人になるということ
little_rubyist
0
200
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.2k
Dev ContainersとGitHub Codespacesの素敵な関係
ymd65536
1
140
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
520
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
4
2.1k
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
310
推し活の ハイトラフィックに立ち向かう Railsとアーキテクチャ - Kaigi on Rails 2024
falcon8823
6
2.7k
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
65
4.4k
A designer walks into a library…
pauljervisheath
202
24k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Statistics for Hackers
jakevdp
796
220k
Bash Introduction
62gerente
608
210k
Adopting Sorbet at Scale
ufuk
73
9.1k
Happy Clients
brianwarren
97
6.7k
We Have a Design System, Now What?
morganepeng
50
7.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
How GitHub (no longer) Works
holman
310
140k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
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
ϒϩάʹ·ͱΊΔ