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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
11
最近やった作業環境改善施策10個
mattak
0
310
UnixTime is Simple
mattak
0
270
おっさんが停滞しないために
mattak
32
19k
tech invest
mattak
1
370
Nodux - node base redux framework
mattak
0
1.6k
what_is_technical_investment
mattak
0
190
unitypackage distribution
mattak
0
890
Unity energy usage
mattak
0
990
Other Decks in Programming
See All in Programming
1B+ /day規模のログを管理する技術
broadleaf
0
130
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
250
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
570
Performance Engineering for Everyone
elenatanasoiu
0
260
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.7k
AIエージェントで 変わるAndroid開発環境
takahirom
1
430
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
830
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
860
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
280
スマートグラスで並列バイブコーディング
hyshu
0
280
なぜ型を書くのか? TSKaigi2026で改めて考える #tskaigi_smarthr
kajitack
0
210
Featured
See All Featured
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
180
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
410
The Pragmatic Product Professional
lauravandoore
37
7.4k
How to Ace a Technical Interview
jacobian
281
24k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
380
Raft: Consensus for Rubyists
vanstee
141
7.6k
Typedesign – Prime Four
hannesfritz
42
3.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Mind Mapping
helmedeiros
PRO
1
280
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
410
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