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
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Slackであそぼ!!
KFIE第一回LT会
コードはこちら→
https://gist.github.com/moririn772/de452d19f7c91bfce902e4d8201c16fc
Keisuke Mori
June 14, 2019
More Decks by Keisuke Mori
See All by Keisuke Mori
AWSを使う上で意識しておきたい、クラウドセキュリティ超入門(駆け足版)
kkmory
1
430
[JAWS-SG#02] 個人開発やハッカソンで役立つ、便利APIのつくりかた
kkmory
0
160
rubyonjets_with_aws_for_research
kkmory
0
610
AWSで動画変換&配信基盤を作った話
kkmory
0
260
Git-study-Hackz-treasure
kkmory
1
290
飯塚ブロックチェーン勉強会 #1
kkmory
0
150
Swarm: The distributed storage platform
kkmory
1
840
Kindai_Blockchain_study01
kkmory
0
270
Other Decks in Technology
See All in Technology
AIが自律的に回る開発ループを設計してチーム開発に組み込む
nekorush14
0
120
事業会社における 機械学習・推薦システム技術の活用事例と必要な能力 / ml-recsys-in-layerx-wantedly-2026
yuya4
0
160
自分が詳しくない領域でAIを使う #プロヒス2026
konifar
20
7.4k
從開發到部署全都交給 AI:實作 AI 驅動的自動化流程
appleboy
0
160
水を運ぶ人としてのリーダーシップ
izumii19
4
990
AI 不只幫你寫 Code: 當專案從 300 暴增到 1500, 我們如何撐住 DevOps
appleboy
0
220
感情と身体を置き去りにしない、エンジニアの生きのこり方 ──いまから、ここから「自分の状態」を扱うという選択
saorimurooka
0
330
“詰む”前に仕組みを作れ 〜技術の波に溺れないためのキャッチアップ術〜
takasyou
7
3.7k
本当の”仕事”を手放せる未来が見えた
mu7889yoon
0
110
Microsoft のサポートとフィードバック総まとめ
murachiakira
PRO
0
110
Claude Codeをどのように キャッチアップしているか
oikon48
13
8.8k
生成 AI 実践ガイド (概略版) AIガバナンス編
asei
0
190
Featured
See All Featured
The Curse of the Amulet
leimatthew05
2
13k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
180
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
480
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
180
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
850
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
250
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
200
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
毎週水曜日 天神のどこか もくもく会
もくもく会
ゆるーくどこかに集まって 各自もくもくと勉強したり 作業したり本を読んだり するだけの会
初心者大歓迎
興味がある人は 話しかけてね
ありがとうございました