SlideShare une entreprise Scribd logo
1  sur  22
自分専用のslack team & botを作って
圧倒的進捗を得る
A(izu)LT 会津編 0x09 @flying_hato_bus 飛ばすはとバス
自己紹介
氏名 : 飛ばすはとバス ( @flying_hato_bus )
世代 : s124 github : https://github.com/hatobus
ハードウェアが好き,変なものが好き.
今年の夏休みにアメリカのシリコンバレーに行って来ました.
作った主なもの -> 自動で動く赤べこ, レーザーカッターで暗記パン
黄金比を手軽に見つけられる定規
なんでSlackbot作ったの
貧乏暇なしということで色々やることが
たくさんある(授業, バイト, ゴミ出し, 課題)
これ,Google calenderに登録してもいいけど,肝心の時に見てなくて困る.
Slackだったら結構見るし,通知飛ばしてくれるからよくない?
と言うわけで自分の秘書的なのを作りたくなった
名前 … Hatsonくん
(某IBMのあれとグラハム ベルの助手であるワトソンをもじった)
内容 … 授業の予定とかバイトでやることとか,課題の管理
天気,ゴミ出しの日を確認できる.
仕様
サーバー Raspberry pi 3
言語,使用ライブラリ Python 3.5.4 + slackbot
使用API … Open weather map, google calender API
とりあえず動かそう
とりあえず動かしてみる.Slack team を作り,SlackのAPIキーとかを取得して,pythonファイルを作
っていく.
何個かファイルを作る必要があるが,ディレクトリ構造などは上の図を参照していただきたい.
設定ファイルのslackbot_settings.py にAPIキーとデフォルトのリプライを設定して,run.pyにちょっと内容を書
くだけでなんとかなる
この調子でガンガン機能を積んでいく
from slackbot.bot import respond_to
@botname: で反応するデコーダ
from slackbot.bot import listen_to
チャネル内発言で反応するデコーダ
from slackbot.bot import default_reply
該当する応答がない場合に反応するデコーダ
今後使っていくメソッド
@respond_to('string')
メンションがつけられたものに返事をする
‘string’の部分は正規表現で反応できる.
今後使っていくメソッド
@listen_to('string')
botにメンションをつけないで発言した時に反応する.
これも正規表現に対応.
今後使っていくメソッド
message.reply('string')
@発言者名: string でメッセージを送信.リプライを送ってくれる
message.send('string')
string を送信
コードの例
天気について教えてもらえるようにする
こういうのにもってこいなのが多分お天気の情報.
スマホとかで手軽に調べることができるけど,そういうのも面倒な時は
Hatsonくんに教えてもらえるようにする.
使用したAPI : Open weather map ( https://openweathermap.org/ )
要件
「 〇〇 の天気」とチャンネルに書くと,APIを叩いてお天気情報を教えてくれる
Open weather mapのAPIをpythonで叩いて,jsonファイルをスクレイピングして情報取得.
正規表現が使えるので 都市名の取得は「 (. * ) 」でできる.
場所を都市名と緯度経度で指定できたが,今回はpythonのGeocoderを使い,緯度経度で
天気を取得できるようにした.
実装
デモ
作ってわかったこと
これくらいじゃ†圧倒的進捗†は得られそうにないので,目下開発を進めていくしかない.
TODOとしてはGoogleカレンダーと連携したい. -> やってみたらAPI周りで詰んだ webの知識のNASA
ゴミの日とかにメンション飛ばしてくれたらいいかなって感じ
参考文献等
PythonのslackbotライブラリでSlackボットを作る
Slack API 推奨Tokenについて
Slackbotライブラリの公式レポジトリ
Slide shareの投稿
( https://qiita.com/sukesuke/items/1ac92251def87357fdf6 )
( https://qiita.com/ykhirao/items/3b19ee6a1458cfb4ba21 )
( https://github.com/lins05/slackbot )
( https://www.slideshare.net/BusHato/alt2017-1111-81874535 )

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Alt2017 1111 hatobus