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
Slackであそぼ!!
Search
Keisuke Mori
June 14, 2019
Technology
0
140
Slackであそぼ!!
KFIE第一回LT会
コードはこちら→
https://gist.github.com/moririn772/de452d19f7c91bfce902e4d8201c16fc
Keisuke Mori
June 14, 2019
Tweet
Share
More Decks by Keisuke Mori
See All by Keisuke Mori
AWSを使う上で意識しておきたい、クラウドセキュリティ超入門(駆け足版)
kkmory
1
420
[JAWS-SG#02] 個人開発やハッカソンで役立つ、便利APIのつくりかた
kkmory
0
150
rubyonjets_with_aws_for_research
kkmory
0
600
AWSで動画変換&配信基盤を作った話
kkmory
0
250
Git-study-Hackz-treasure
kkmory
1
280
飯塚ブロックチェーン勉強会 #1
kkmory
0
150
Swarm: The distributed storage platform
kkmory
1
830
Kindai_Blockchain_study01
kkmory
0
260
Other Decks in Technology
See All in Technology
Laravelで学ぶOAuthとOpenID Connectの基礎と実装
kyoshidaxx
4
1.6k
OpenClaw を Amazon Lightsail で動かす理由
uechishingo
0
250
FastMCP OAuth Proxy with Cognito
hironobuiga
3
110
2026年もソフトウェアサプライチェーンのリスクに立ち向かうために / Product Security Square #3
flatt_security
1
740
WebアクセシビリティをCI/CDで担保する ― axe DevTools × Playwright C#実践ガイド
tomokusaba
2
200
"作る"から"使われる"へ:Backstage 活用の現在地
sbtechnight
0
230
スピンアウト講座02_ファイル管理
overflowinc
0
520
AWS Systems Managerのハイブリッドアクティベーションを使用したガバメントクラウド環境の統合管理
toru_kubota
0
110
Escape from Excel方眼紙 ~マークダウンで繋ぐ、人とAIの架け橋~ /nikkei-tech-talk44
nikkei_engineer_recruiting
0
150
新規事業×QAの挑戦:不確実性を乗りこなす!フェーズごとに求められるQAの役割変革
hacomono
PRO
0
150
形式手法特論:SMT ソルバで解く認可ポリシの静的解析 #kernelvm / Kernel VM Study Tsukuba No3
ytaka23
1
720
Goのerror型がシンプルであることの恩恵について理解する
yamatai1212
1
280
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Design in an AI World
tapps
0
180
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
480
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
790
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
91
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Become a Pro
speakerdeck
PRO
31
5.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
150
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
770
Context Engineering - Making Every Token Count
addyosmani
9
770
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Balancing Empowerment & Direction
lara
5
960
Transcript
Slackであそぼ! KFIE第一回LT会 森 啓輔
自己紹介
もりけいすけ @moririn772
山崎ゼミ3年
Bitcoin
Ruby
None
None
ブロックチェーン ウェブ の人 Ruby }
であそぶ
None
≒
用意するもの
Slack Ruby heroku*1 *1 : 自動化したいなら必要
以上
やり方は簡単
Step 1
Slackの設定
開発者向けページに飛んで https://api.slack.com/
つくるアプリのいろいろを決めて
BOTをつくって
ワークスペースに追加!
か ら の
遊び場チャンネルをつくって
チャンネルにいれる! 今回は #playground とします
Step 2
コーディング
処理の流れ
全体の流れ 天気くれ!
全体の流れ 天気あげる〜
全体の流れ ごにょごにょ
全体の流れ 投稿して!
全体の流れ 投稿ぽーん!
全体の流れ おk
全体の流れ おk
全体の流れ やったー!
コードをみてみよう
HTTPを使えるようにする gem install http コンソール
Rubyファイルをつくる touch otenki.rb コンソール
ライブラリを読み込む require 'http' require 'json' require 'open-uri' require 'time' otenki.rb
お天気情報を取得する def get_and_format response = "" open(@uri) {|f| f.each_line {|l|
response << l} } format(response) end otenki.rb
必要な項目だけ抽出 w = JSON.parse(response) title = w["title"] text = w["description"]["text"]
time = Time.parse(w[“description"] [“publicTime"]).strftime("%Y %m݄%d") otenki.rb
Slackに投げる response = HTTP.post("https://ུ params: { token: 4IPKcPRmH9faFKaf, channel: “#playground”,
text: message, as_user: true, }) otenki.rb
完成形はこちら https://gist.github.com/moririn772/de452d19f7c91bfce902e4d8201c16fc
注意事項
このコードは このまま公開しないでね
Access Token = 秘密情報
response = HTTP.post("https://ུ params: { token: 4IPKcPRmH9faFKaf, channel: channel, text:
message, as_user: true, }) otenki.rb これ!!!!
Token があれば遊び放題 (流出すると悪用の危険)
環境変数で設定しましょう (詳しくはWEBで)
Step 3
やってみる
実行する ruby otenki.rb コンソール
None
えっ手動とか ダサくない?
平日の朝8:00に 教えてほしい
Heroku Scheduler https://elements.heroku.com/addons/scheduler
平日の8:00 とか 指定時間に 投稿できる
以前こんなものを…
まとめ
やったこと Slack側の設定 コードを書く 手動で動作確認
やってないこと 秘密情報の保護 自動化
続きはウェブで
まだ全然できてないです
今週末に公開予定(未定)
みんなもあそんでみよう !
余談
Rubyに興味がある "
Fukuoka.rb
毎週水曜日 天神のどこか もくもく会
もくもく会
ゆるーくどこかに集まって 各自もくもくと勉強したり 作業したり本を読んだり するだけの会
初心者大歓迎
興味がある人は 話しかけてね
ありがとうございました