Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Slack bot をGoでつくってみた
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Kutsuzawa Ryo
July 09, 2018
Programming
180
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Slack bot をGoでつくってみた
golang 気持ちい
Kutsuzawa Ryo
July 09, 2018
More Decks by Kutsuzawa Ryo
See All by Kutsuzawa Ryo
大企業でもできる!短期間でプロダクトローンチするための勘所
oliva
8
6.6k
Recap: `How Uber "Go"es` in Japanese
oliva
0
250
Other Decks in Programming
See All in Programming
Agents on Rails - Rails at Scale 2026
irinanazarova
0
200
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.9k
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
130
setup-vp GitLab対応の裏側
naokihaba
0
120
アクセシビリティから考える情報設計
high_g_engineer
0
390
Workers Cache を知る
syumai
0
210
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
280
速習iPhone Duo対応
yuukiw00w
2
720
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
3.1k
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
390
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
190
The Rails Doctrine Decade
koic
2
360
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Six Lessons from altMBA
skipperchong
29
4.5k
Technical Leadership for Architectural Decision Making
baasie
3
580
The Curse of the Amulet
leimatthew05
3
15k
Ruling the World: When Life Gets Gamed
codingconduct
0
360
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
310
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
My Coaching Mixtape
mlcsv
0
320
Darren the Foodie - Storyboard
khoart
PRO
4
3.9k
Making Projects Easy
brettharned
120
6.8k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
430
Transcript
4MBDL#PUΛ (PͰ࡞ͬͯΈͨ HPQIFSEPKP-5 3ZP,VUTV[BXB !CPPLVO
ࣗݾհ n 沓澤 遼 pGitHub: https://github.com/bookun pQiita: https://qiita.com/bookun nお仕事 pServer
Side Engineer ØPHP / Laravel or CakePHP ngopher道場参加のきっかけ p興味のあるプロダクトでgo製のものが多かった ØDocker ØCloud Foundry ØMinio (https://github.com/minio/minio) Qiita投稿記事のタグ⽐率
4MBDL#PU Λ࡞ͬͯΈͨཧ༝ ˢ 社内のこれをなくしたかったから それSlack内から サクッと ⼊れれるよー GitHubとSlackでユーザネームが違うから結局アレをやられてしまう恐れ!! GitHubの名前 しかし。。
1VMM3FRVFTUͷ3FWJFXґཔ͕ ͖ͨͱ͖ʹɺ4MBDLͰϝϯγϣϯΛ ͚ͭͯ௨ͯ͘͠ΕΔ#PUΛ(PͰ ࡞Γ͍ͨ
(JUIVC㱺#PU㱺4MBDL GitHubがPull Requestイベントを検知するとBotに対してJSONがPOSTされる https://<heroku appのURL>/ にPOSTがきたら 上記のハンドルで処理 レビュー依頼のみ取り扱った。 イベントの種類ごとにJSONが異なるため、 イベント毎にJSONをDecodeするための
構造体を宣⾔する必要がある。 Ex) var requestedPR pr.PR
(JUIVC㱺#PU㱺4MBDL PRの情報が格納されたJSONをDecodeする 道場の第4回⽬でやったやつ!?!? GitHubからのJSON JSONデコード⽤の構造体をどう定義するか??? 講義のものよりプロパティが多い。 デコード⽤の構造体を定義するのが困難。
(JUIVC㱺#PU㱺4MBDL JSONからデコード⽤構造体を⽣成してくれるWebサービス (https://mholt.github.io/json-to-go/)
(JUIVC㱺#PU㱺4MBDL 第4回⽬でやったやつ!! GitHubからのJSON JSONデコードのための構造体の定義 PRの情報が格納されたJSONをDecodeする
(JUIVC㱺#PU㱺4MBDL 以下の3つの情報が必要 n SlackのWebhook n Channel名 n 本⽂ (text or
attachment) Attachment構造体 それっぽいメッセージが送れた!! Mentionになってない!! しかし
4MBDL㱺#PU GitHub名とSlack名の対応表が欲しい。 SlackにAppを作り、Slash Commandを作った /useradd <GitHub名> @<Slack名> ⇒ https://<heroku appのURL>/commandsへPOST
https://<heroku appのURL>/commands に POSTがきたら上記のハンドラで処理 user.Add() にてDBに Github名に対するSlack名の 情報を格納したかったが今回は時間の関係で断念。 環境変数に保存させるようにした。 SlackからのPOST内容
4MBDL㱺#PU /useradd コマンドを打つ
4MBDL㱺#PU 補⾜ 環境変数にgithub名=slack名で 格納されていればなんでもよい。 • .envに記載 • heroku config:set •
heroku web UIから • /useradd Mentionキタ!! 再度 Review依頼を送る
1VMM3FRVFTUͷ3FWJFXґཔ͕ ͖ͨͱ͖ʹɺ4MBDLͰϝϯγϣϯΛ ͚ͭͯ௨ͯ͘͠ΕΔ(Pͷ#05 https://github.com/bookun/slackbot
·ͱΊ https://deeeet.com/writing/2016/10/25/go-interface-testing/ より引⽤ 道場での受講中、様々な記事に助けていただきました。 ありがとうございました!! n 薄い⾔語仕様 Ø 暗記事項みたいなものが少ない n
Testやhttp serverそのものもピュアなGolangで⼗分に書くことができる Ø golangを知っているだけで理解できることが多い n 使われていない変数があると怒られる Ø 定義された変数は必ずどこかで使われているはずだから確実に読む価値がある n (vim-goを⼊れるだけで⼗分にvimでコーディングできる) Ø (宗教戦争なので議論はしないが、vimでGolangを書くのが気持ちがいい) 私が感じたGolangの気持ちがいいところ