Filter words

This commit is contained in:
rnhmjoj 2015-10-01 16:08:43 +02:00
parent e19085bf17
commit b0698f2708

View File

@ -36,8 +36,10 @@ module.exports = (robot) ->
"http://dogr.io/#{escape text}.png?split=false" "http://dogr.io/#{escape text}.png?split=false"
shiba = (res, words) -> shiba = (res, words) ->
word = words.filter (x) -> x.length > 4
prefix = [ 'much', 'such', 'many', 'very'] prefix = [ 'much', 'such', 'many', 'very']
word = words.filter (x) ->
/^[a-zA-ZàèéìòùÀÈÉÌÒÙ\-_!&@#?]{4,}$/.test x
console.log word
(res.random prefix) + ' ' + (res.random words) (res.random prefix) + ' ' + (res.random words)
run_command = (command, callback) -> run_command = (command, callback) ->
@ -59,7 +61,7 @@ module.exports = (robot) ->
callback ((match_all regex, lines.join '\n').map parse_line) callback ((match_all regex, lines.join '\n').map parse_line)
robot.respond /doge(?: (\d+))?/, (res) -> robot.respond /doge(?: (\d+))?/, (res) ->
n = res.match[1] || 10 n = res.match[1] || 20
get_history res.message.room, n, (history) -> get_history res.message.room, n, (history) ->
words = concat (message.text.split ' ' for message in history) words = concat (message.text.split ' ' for message in history)
sample = (res.random ['wow', shiba res, words] for _ in [0..8]) sample = (res.random ['wow', shiba res, words] for _ in [0..8])