3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Hubotで対話的ズンドコキヨシ

Last updated at Posted at 2016-03-18

CoffeeScriptで挑戦した勢いで書きました。

module.exports = (robot) ->
  zdk = (zun1)->
    zun2 = yield zun1 is 'ズン'
    zun3 = yield zun2 is 'ズン'
    zun4 = yield zun3 is 'ズン'
    doko1 = yield zun4 is 'ズン'
    delete robot.zdk
    if doko1 is 'ドコ' then 'キ・ヨ・シ!!' else false

  nextZdk = (input)->
    robot.zdk.next(input).value

  robot.respond /(ズン|ドコ)$/i, (msg)->
    unless robot.zdk
      robot.zdk = zdk(msg.match[1])
    res = nextZdk msg.match[1]
    if typeof res is 'string'
      msg.send res
    else
      unless res
        delete robot.zdk

最後にしゃべらせる部分が微妙な気がしますね。

せっかくなのでSlack上で
無題.png

追記

npmに初挑戦がてら登録してみました。
https://www.npmjs.com/package/hubot-zundoko

ご自分のhubotともズンドコしたい!という方はぜひ。
hubotのルートディレクトリに移動したら下記コマンドでインストールできます。

$ npm install --save hubot-zundoko
$ echo '["hubot-zundoko"]' > external-scripts.json

参考
http://qiita.com/satzz/items/0a5875fae0f5731cc8f8
http://saihoooooooo.hatenablog.com/entry/2013/12/07/052150

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?