hubotでズンドコチェック
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
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