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
HubotでIRC botをつくろう
Search
mattak
July 23, 2014
Programming
650
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
HubotでIRC botをつくろう
Hubot勉強会 2014/07/23
mattak
July 23, 2014
More Decks by mattak
See All by mattak
人間はどこまでさぼれるか? AIコーディングで人の関与を計測してみた
mattak
0
3
最近やった作業環境改善施策10個
mattak
0
300
UnixTime is Simple
mattak
0
260
おっさんが停滞しないために
mattak
32
18k
tech invest
mattak
1
370
Nodux - node base redux framework
mattak
0
1.6k
what_is_technical_investment
mattak
0
180
unitypackage distribution
mattak
0
890
Unity energy usage
mattak
0
980
Other Decks in Programming
See All in Programming
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
320
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
490
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
180
AI時代のUIはどこへ行く?その2!
yusukebe
21
7k
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
LLM Plugin for Node-REDの利用方法と開発について
404background
0
170
Contextとはなにか
chiroruxx
0
280
Swiftのレキシカルスコープ管理
kntkymt
0
220
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
700
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
150
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.3k
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
Featured
See All Featured
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
570
Rails Girls Zürich Keynote
gr2m
96
14k
Site-Speed That Sticks
csswizardry
13
1.2k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.7k
GraphQLとの向き合い方2022年版
quramy
50
15k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
720
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Everyday Curiosity
cassininazir
0
230
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
390
ラッコキーワード サービス紹介資料
rakko
1
3.6M
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
170
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Transcript
HubotͰ IRC BotΛͭ͘Ζ͏ 2014 / 07 / 23 @mattak
AGENDA 1. Hubot ͱʁ 2. Hubot ͷ࡞Γํ 3. Hubot ͰεΫϦϓτΛॻ͘
4. εΫϦϓτΛެ։͢Δ
Hubot?
Hubot? • Human + Robot = Hubot ? • GithubࣾͷChat
bot ! • ݴޠ: Coffeescript • ڥ: HipChat, IRC, Twitter, Gtalk, Skype, Linger,… • ύοέʔδཧ: npm
ಛ1: ͍ΖΜͳαʔϏεͰಈ͘
ಛ2: moduleԽͰ͖Δ Adapter tinyspec/hubot-slack nandub/hubot-irc miyagawa/hubot-lingr script hubot-ascii-faces hubot-cron hubot-yo
ಛ3: redisͰঢ়ଶཧ - BotΛ࠶ىಈͯ͠େৎ / / data set robot.brain.data[“user”] =
0; ! / / data save robot.brain.save();
Ͳ͏ͬͯ࡞Δ?
install -> create -> launch $ npm install -g hubot
coffee-script $ hubot —create myhubot $ cd myhubot $ bin/hubot —name myhubot myhubot> myhubot help …. default ͩͱShell্Ͱىಈ͠·͢ɻ
IRCͷରԠ $ npm install hubot-irc —save && npm install $
HUBOT_IRC_SERVER=irc.example.com \ HUBOT_IRC_ROOMS=“#room1,#room2” \ HUBOT_IRC_NICK=“myhubot” \ HUBOT_IRC_UNFLOOD=“true” \ bin/hubot -a irc —name myhubot HUBOT_IRC_SEND_NOTICE_MODE = “true” noticeͰͷىಈ
hubotͷݺͼํ myhubot> myhubot help myhubot> @myhubot help myhubot> MYHUBOT help
myhubot> myhubot: help
defaultͰ৭ʑͰ͖ΔΑ ը૾ Hubot> @Hubot image me ॅ఼ youtube: Hubot> @Hubot
youtube me ͪΐͬͱ͓࣌ؒΑΖ͍͠Ͱ͔͢ ݴޠม: Hubot> @Hubot translate me from japanese into english δϣδϣ Ξχϝʔγϣϯgif: Hubot> @Hubot animate me খࣉখ࡙
pluginͷΠϯετʔϧ $ npm install hubot-cron —save $ cat external-scripts.json [“hubot-cron”]
npm install ͯ͠ɺexternal-scripts.jsonʹهड़͢Δ͚ͩ.
scriptΛॻ͘ʂ
scripts $ ls scripts auth.coffee google-images.coffee httpd.coffee ping.coffee roles.coffee storage.coffee
youtube.coffee events.coffee help.coffee maps.coffee pugme.coffee rules.coffee translate.coffee ਅࣅ͠ͳ͕Βɺscripts/ ҎԼʹॻ͚OK.
scriptͷίϝϯτ https:/ /github.com/github/hubot-scripts#readme # Description # <description of the scripts
functionality> # # Dependencies: # "<module name>": "<module version>" # # Configuration: # LIST_OF_ENV_VARS_TO_SET # # Commands: # hubot <trigger> - <what the respond trigger does> # <trigger> - <what the hear trigger does> # # Notes: # <optional notes required for the script> # # Author: # <github username of the original script author> ॻ͘ͱhelpʹग़Δʂ
scriptͷத module.exports = (robot) -> robot.respond /PING$/i, (msg) -> msg.send
"PONG" ! robot.respond /ADAPTER$/i, (msg) -> msg.send robot.adapterName ! robot.respond /ECHO (.*)$/i, (msg) -> msg.send msg.match[1] ! robot.respond /TIME$/i, (msg) -> msg.send "Server time is: #{new Date()}" ! robot.respond /DIE$/i, (msg) -> msg.send "Goodbye, cruel world." process.exit 0
tips1 msg.send “Guten morgen!” ൃݴ͢Δ msg.reply “ͳΜͰͶΜʂ” ฦ͢Δ Hubot> @Hubot
tukkomi Hubot> Shell: “ͳΜͰͶΜʂ” Hubot> Guten morgen!
tips2 robot.hear /hear/i, (msg) -> msg.send “hear” Ԡ1 robot.respond /respond/i,
(msg) -> msg.send “respond” Ԡ2 Hubot> @Hubot hear Hubot> hear Hubot> @Hubot respond Hubot> respond Hubot> respond Hubot> hear Hubot> hear (respond: @Hubot Ͱ࢝ΊΔίϚϯυܥ) (hear: ҙԠܥ)
tips3 { "user": { "id": "1", "name": "Shell", "room": "Shell"
}, "text": "@Hubot test", "id": "messageId", "done": false, "room": "Shell" } ൃݴ༰: msg.message bot໊: robot.name
moduleԽͯ͠ެ։͢Δ!
࣮ࡍʹͭͬͯ͘Έͨ • https:/ /github.com/mattak/hubot-hello-ninja • https:/ /www.npmjs.org/package/hubot-hello-ninja ࢀߟ: • https:/
/github.com/sakatam/hubot-yo • https:/ /github.com/miyagawa/hubot-cron
؆୯Ͱ͢ ొ: $ npm adduser ެ։: $ npm publish ֬ೝ:
$ npm info hubot-hello-ninja ಈ࡞֬ೝ: $ npm install /your/module/path
HubotΦεεϝʂ ͲΜͲΜmoduleԽ͠Α͏ʂ
࣌ؒ͋ΔͷͰDEMO https:/ /github.com/mattak/ninja-bot