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
12
最近やった作業環境改善施策10個
mattak
0
310
UnixTime is Simple
mattak
0
270
おっさんが停滞しないために
mattak
32
19k
tech invest
mattak
1
380
Nodux - node base redux framework
mattak
0
1.6k
what_is_technical_investment
mattak
0
190
unitypackage distribution
mattak
0
900
Unity energy usage
mattak
0
990
Other Decks in Programming
See All in Programming
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
720
Embedded SREと共に達成した会員管理システムのAWS移行 - SRE NEXT 2026 ランチスポンサーセッション
niftycorp
PRO
1
3.3k
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
420
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
290
FDEが実現するAI駆動経営の現在地
gonta
2
240
霧の中の代数的エフェクト
funnyycat
1
450
メールのエイリアス機能を履き違えない
isshinfunada
0
190
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
610
yield再入門 #phpcon
o0h
PRO
0
860
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
380
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
180
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
620
Featured
See All Featured
Test your architecture with Archunit
thirion
1
2.3k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
200
The Spectacular Lies of Maps
axbom
PRO
1
880
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.8k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
400
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
200
Skip the Path - Find Your Career Trail
mkilby
1
170
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
370
How to build a perfect <img>
jonoalderson
1
5.8k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
500
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