Last active
January 8, 2018 09:23
-
-
Save wagawo/77a1757cae77f439d0c1fe8d2facd3df to your computer and use it in GitHub Desktop.
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