Skip to content

Instantly share code, notes, and snippets.

@wagawo
Last active January 8, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wagawo/77a1757cae77f439d0c1fe8d2facd3df to your computer and use it in GitHub Desktop.
Save wagawo/77a1757cae77f439d0c1fe8d2facd3df to your computer and use it in GitHub Desktop.
hubotでズンドコチェック
###
Description: ズンドコチェック
Note:
・'ズン'または'ドコ'を等確率で出力する。
・直近の出力が'ズンズンズンズンドコ'だった場合、'キ・ヨ・シ!'を出力して処理を停止する。
・各出力において、改行の有無は問わない。
###
module.exports = (robot) ->
robot.respond /(zundoko|ズンドコ|ずんどこ)/i, (msg) ->
ZUN = "ズン"
DOKO = "ドコ"
KIYOSHI = "キ・ヨ・シ!"
zundoko = ""
count = 0
while true
if (Math.floor(Math.random() * 2) + 1) % 2 == 0
zundoko += ZUN
else
zundoko += DOKO
if (zundoko.match(/(ズン){4}(ドコ)/i) )
break
count++
message = zundoko + KIYOSHI + "\n最小値+#{count-4} " + ZUN + DOKO
msg.send "#{message}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment