Created
November 17, 2015 01:51
-
-
Save keita03301995/982d1b3b17fa5b947ec0 to your computer and use it in GitHub Desktop.
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
module.exports = (robot) -> | |
robot.hear /突然の(.*)/i,(res) -> | |
str = res.match[1] | |
res.send "#{str}" | |
len = str.length | |
res.send len | |
if len > 0 | |
ans = ('人' for i in [0..len]) | |
ans = ans.replace(/,/g, "") | |
res.send "#{ans}" | |
////////////////////////////////////////////////////////////////////////// | |
突然の死 | |
jecbot> [Tue Nov 17 2015 10:42:12 GMT+0900 (JST)] DEBUG Message '突然の死' matched regex //突然の(.*)/i/ | |
[Tue Nov 17 2015 10:42:12 GMT+0900 (JST)] DEBUG Executing listener callback for Message '突然の死' | |
死 | |
1 | |
[Tue Nov 17 2015 10:42:12 GMT+0900 (JST)] ERROR TypeError: Object 人,人 has no method 'replace' | |
at TextListener.callback (/home/ec2-user/keita/jecbot/scripts/sudden.coffee:9:4, <js>:18:19) | |
at executeListener (/home/ec2-user/keita/jecbot/node_modules/hubot/src/listener.coffee:65:11, <js>:53:19) | |
at allDone (/home/ec2-user/keita/jecbot/node_modules/hubot/src/middleware.coffee:41:37, <js>:32:16) | |
at /home/ec2-user/keita/jecbot/node_modules/hubot/node_modules/async/lib/async.js:274:13 | |
at Object.async.eachSeries (/home/ec2-user/keita/jecbot/node_modules/hubot/node_modules/async/lib/async.js:142:20) | |
at Object.async.reduce (/home/ec2-user/keita/jecbot/node_modules/hubot/node_modules/async/lib/async.js:268:15) | |
at /home/ec2-user/keita/jecbot/node_modules/hubot/src/middleware.coffee:46:7, <js>:35:22 | |
at process._tickCallback (node.js:442:13) | |
配列の中身を"人,人"にする事ができたのですが、そのまま表示するとカンマも一緒に出力されてしまうので | |
「str.replace」を使用してカンマを消そうと試みたのですが、エラーが。。。 | |
もし上手いやり方があれば是非教えてくだされっ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment