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
Errbotで得られる、ChatOps入門
Search
attakei
September 06, 2017
Programming
1.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Errbotで得られる、ChatOps入門
PyconJP Reject Conference 2017 (
https://techplay.jp/event/630686
) で発表したスライドです
attakei
September 06, 2017
More Decks by attakei
See All by attakei
Sphinxを通して考える、「拡張」の仕方 / First approach for development sphinx extension
attakei
2
4.9k
PyPIデビュー手前の人のための地下活動手法 -PyPICloudを使ったプライベートレジストリの構築- / Using PyPICloud as private registry for pre-debut to PyPI
attakei
1
650
「〇〇のプラグインを作る」ことのすゝめ / Let's develop plugins
attakei
0
1.3k
プレゼン?それもSphinxで出来るよ -ドキュメントツールSphinxのちょっと変わった利用法- / You can presentation too by Sphinx!
attakei
1
1.6k
Cloud RunとFastAPIで、ChatBotをミニマムスタートしよう / Getting start ChatBot with FastAPI and Cloud RUN
attakei
0
3.2k
Web制作において、プレビューにあえてCloudRun(とFirebase)を使う / Using Cloud Run (and Firebase) as preview environment of HTML in web development
attakei
0
1.5k
Ansibleを通じて「べき等性」を 理解してみよう / Try understanding idempotency by Ansible
attakei
1
1.5k
素材の良さを活かしつつ、reST をReveal.jsに変換してみる話 / Converting pure reST to Revealjs
attakei
0
550
Eelで作ってみる WHOISアプリと スライド
attakei
0
1.1k
Other Decks in Programming
See All in Programming
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
280
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
810
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
970
Oxcを導入して開発体験が向上した話
yug1224
4
340
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
860
これからAgentCoreを触る方へトレンドはGatewayです
har1101
2
300
The NotImplementedError Problem in Ruby
koic
1
960
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
8.5k
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
140
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.4k
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
210
Git: the NoSQL Database
bkeepers
PRO
432
67k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
Why Our Code Smells
bkeepers
PRO
340
58k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
210
Build your cross-platform service in a week with App Engine
jlugia
234
18k
For a Future-Friendly Web
brad_frost
183
10k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
Un-Boring Meetings
codingconduct
0
320
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ユーザーが増えることを願いつつ