Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Errbotで得られる、ChatOps入門
attakei
September 06, 2017
Programming
0
1k
Errbotで得られる、ChatOps入門
PyconJP Reject Conference 2017 (
https://techplay.jp/event/630686
) で発表したスライドです
attakei
September 06, 2017
Tweet
Share
More Decks by attakei
See All by attakei
PyPIデビュー手前の人のための地下活動手法 -PyPICloudを使ったプライベートレジストリの構築- / Using PyPICloud as private registry for pre-debut to PyPI
attakei
1
160
「〇〇のプラグインを作る」ことのすゝめ / Let's develop plugins
attakei
0
540
プレゼン?それもSphinxで出来るよ -ドキュメントツールSphinxのちょっと変わった利用法- / You can presentation too by Sphinx!
attakei
0
230
Cloud RunとFastAPIで、ChatBotをミニマムスタートしよう / Getting start ChatBot with FastAPI and Cloud RUN
attakei
0
1.8k
Web制作において、プレビューにあえてCloudRun(とFirebase)を使う / Using Cloud Run (and Firebase) as preview environment of HTML in web development
attakei
0
670
Ansibleを通じて「べき等性」を 理解してみよう / Try understanding idempotency by Ansible
attakei
1
580
素材の良さを活かしつつ、reST をReveal.jsに変換してみる話 / Converting pure reST to Revealjs
attakei
0
130
Eelで作ってみる WHOISアプリと スライド
attakei
0
650
Ansibleで作る、AWSで「器の大きい」Omnibus-GitLab
attakei
2
1.8k
Other Decks in Programming
See All in Programming
実践エクストリームプログラミング / Extreme Programming in Practice
enk
1
300
One does not simply: migrating to Android 12 🤯
oleur
1
120
io22 extended What's new in app performance
veronikapj
0
330
Modern Android Developer ~ 안내서
pluu
1
570
設計ナイト2022 トランザクションスクリプト
shinpeim
11
2k
Jakarta EE 10 - Feature by Feature with My Open Source Journey
ivargrimstad
0
1.9k
模組化的Swift架構(二) DDD速成
haifengkao
0
330
Angular‘s Future without NgModules: Architectures with Standalone Components @enterJS
manfredsteyer
PRO
0
170
Voiceflowではじめる音声アプリ・チャットボット開発〜2022年版〜 / Introduction to Developing Voice Apps & Chatbots with Voiceflow
kun432
0
170
Springin‘でみんなもクリエイターに!
ueponx
0
120
即、New Relic / New Relic NOW!
uzulla
0
270
IE Graduation (IE の功績を讃える)
jxck
20
12k
Featured
See All Featured
A Philosophy of Restraint
colly
192
15k
Streamline your AJAX requests with AmplifyJS and jQuery
dougneiner
126
8.5k
Building Applications with DynamoDB
mza
83
4.7k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
5.9k
Principles of Awesome APIs and How to Build Them.
keavy
113
15k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
269
11k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
Pencils Down: Stop Designing & Start Developing
hursman
112
9.8k
Faster Mobile Websites
deanohume
294
28k
How GitHub (no longer) Works
holman
296
140k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.3k
Build your cross-platform service in a week with App Engine
jlugia
219
17k
Transcript
Errbotによって得られる、 ChatOpsライフ入門 PyconJP Reject Conference 2017 株式会社ニジボックス 武居和也
Agenda l自己紹介 l【PR】ニジボックスについて lChatBotとChatOps lErrbotについて lErrbotの始め方 lcommandを作る l便利な機能を知る
> 自己紹介 lKazuya Takei l株式会社ニジボックス lインフラ関係 l事業外全般 lエンジニアに啓蒙する系 l@attakei lTwitter/GitLab/GitHub/Qiita
l技術的に面白そうなら、雑に手を出すタイプ
> 【PR】ニジボックスについて lNIJIBOX Co., Ltd. lhttps://nijibox.jp lリクルートグループ発の新規事業開発会社 lやってること l新規事業開発の支援 lO2Oキャンペーン受託
l自社サービス/パッケージ l レシポ l Biztom
> 雑) ChatBot と ChatOps ChatBot = Chat + Bot
Øチャット(Chat)サービスのインターフェースを介して 自動で動作するプログラム(Bot) ⦁ 自然対話が主目的 ⦁ ChatOpsが主目的 ChatOps = Chat + Ops Øチャット(Chat)サービスをベースに システム運用(Ops)をしていくこと
Errbotについて
> Errbotについて lPython製のChatBotフレームワーク lhttp://errbot.io/ lhttps://github.com/errbotio/errbot lhubot, rubotyなどが類似ライブラリ lバージョン: 5.1.2 (2017/09/06現在)
l現行バージョンはPython3.3以降のみ対応 lプラグイン方式
> Errbotについて (2) Backend plugin Storage plugins User plugins
> Backend plugins <Built in> •Slack •HipChat •Telegram •XMPP •IRC
•Text •Local GUI <Community> •Gitter •Skype •Discord •Mattermost •Cisco Spark
> Storage plugins <Built in or Official> •Shelf •SQL •Google
Cloud Datastore <Community> •Redis •RethinkDB
Errbotの始め方
Errbotの始め方 (1) 最速で始める $ mkdir mybot $ pip install errbot
$ errbot --init $ sed -i -e 's/CHANGE ME/@you/g' config.py $ errbot -T
Errbotの始め方 (2) 構造 + config.py | + data/ | +
plugins/ + err-example/ + example.plug + example.py <-- 設定ファイル <-- 永続データやらなんやら <-- プラグインの置き場その1
Errbotの始め方 (3) l.plugファイルには、プラグインの情報を記述 lErrbot上の名前と使用するモジュール lhelpコマンド時の説明 [Core] Name = Example Module
= example [Documentation] Description = This is a simple plugin
Errbotの始め方 (ex) lGitリポジトリに.plugと対応する.pyファイルが有る なら、reposコマンドでcloneからのプラグインインス トールが可能
commandを 作ってみる
> Errbotのcommand Errbotのコマンドは、デコレータで定義 l@botcmd l@arg_botcmd l@re_botcmd これらを知ってれば、プラグインを作れる
> @botcmd botcmdがBotPluginのメソッドを勝手にcommandと みなす 最終的に何か返せばOKなので、 出来ることの制限は(ほぼ)無い class Example(BotPlugin): @botcmd def
hello(self, msg, args): return 'Hello {}!'.format(msg.frm) >>> !hello Hello you!
> @botcmd メソッド名に _ (アンダースコア)があると、 勝手に半角スペース扱い lcloudfront_create -> cloudfront create
lcloudfront_invalidate -> cloudfront invalidate https://github.com/attakei/errbot-cloudfront/ サブコマンドっぽい!
> @arg_botcmd argparseライクな記述で、commandに引数を指定 することが可能 class Route53(BotPlugin): @arg_botcmd('zone', type=str) def route53_create(self,
msg, zone): # Expression return 'Now creating'
> template Jinja2が利用可能 import boto3 class Route53(BotPlugin): @botcmd(template='route53_list') def route53_list(self,
msg, zone): client = boto3.client('route53') result = client.list_hosted_zones() return {'zones': result['HostedZones']} **List of zones** {% for zone in zones %} - {{ zone.Id }}: {{ zone.Name }} {% endfor %}
> schedule 「定期的に◦ ◦ をさせる」「10分後に◦◦させる」 をやりたいときに from errbot import BotPlugin,
botcmd, arg_botcmd import demo class Example(BotPlugin): @arg_botcmd('min', type=int) def noodle_timer(self, msg, min): self.start_poller(min * 60, self.finished, (msg.frm, min,)) return 'Start {} mins'.format(min) def finished(self, frm, min): self.send(frm, 'Finished') self.stop_poller(self.finished, (frm, min,))
> extra lWebhook lFlow ※今回はスキップ
> Repositories lhttps://github.com/errbotio/errbot lhttps://github.com/attakei/errbot-route53 lhttps://github.com/attakei/errbot-cloudfront lhttps://github.com/attakei/ lhttps://gist.github.com/attakei/6d43b8733d891b9 8a9b6a3bcf9b902a3
ご清聴、ありがとうございました 日本でErrbotユーザーが増えることを願いつつ