Upload
masahitojp
View
650
Download
1
Embed Size (px)
Citation preview
最近のJavaで動くchat bot フレームワークをつくっている話2015.10.10 第13回渋谷Java
tl;drJava8以降で動くHubotみたいなものをつくって、社内で使ってます!
お前誰よ(Who are you?)• Twitter : @Masahito, GitHub: masahitojp
• 株式会社 Skeed所属• 専門はP2Pによる効率的なファイル転送(MiddleWare +
Client)
• ScalaとJVM(v1.6以降)でご飯を食べています。(Java歴2年)
• Loves: Python/Scala/OCaml, Emacs/IntelliJ
まずDemo• https://github.com/masahitojp/botan-example
• on OpenShift
特徴• 牡丹 という名前でつくっています。• pure Java8 (以降)による実装• Lambda をつかった機能追加が可能• パッケージ追加による機能追加に対応• slackとの連携(xmppを利用した)
• Redis/MapDBをつかったデータの保存
examplePingpackage com.github.masahitojp.implementation.handlers;
import com.github.masahitojp.botan.Robot;import com.github.masahitojp.botan.handler.BotanMessageHandlers;
public class PingMessageHandlers implements BotanMessageHandlers { public void register(final Robot robot) { robot.respond( "ping¥z", "ping method", message -> message.reply("pong") ); }}
mavenに上げとくとこんな感じで拡張も可能apply plugin: 'java'
repositories.mavenCentral()
dependencies { compile 'com.github.masahitojp:botan:0.0.1.+' compile 'com.github.masahitojp:botan-mapdb:0.0.1' compile 'com.github.masahitojp:botan-ping:0.0.1'}
sourceCompatibility = targetCompatibility = 1.8
URL本体• https://github.com/masahitojp/botan-core
例• https://github.com/masahitojp/botan-example
• https://github.com/masahitojp/botan-mapdb
つくった動機• Java8でどの程度のことができるのかしりたかった• DevOpsとか格好よさそう!!
• 会社のbotがslack+Hubot
• 社内だとJS/Coffee Script書くのに抵抗がある人が多いのでとりあえずJavaで書こうかなと思った
• 社内用につくってたら、なんかHubotとかに似てきた(^^;
つくって気づいたこと• 機能を会社の後輩につくってもらってるんですが、それに応えて機能拡張
• Lambda 無名クラス使うより読みやすい,思ったより速い• Tuple欲しいなぁ/ Stream便利、だけどだるいなぁ• Clojureでつくられたjubotっていう同じようなものがあるなぁ orz
まぁ勉強になったしいいことにしよう
こんごやりたいこと• XMPPを使わないでSlackと連携• Gitterとの連携• UnitTestをかきやすいようにしていきたい(すごいなやんでます)
• Document書く• 機能の安定化
興味がある方、終わった後でお声がけください!
Question?