Handle partial name match
This commit is contained in:
parent
5d8add17bd
commit
2e5e6760a5
@ -65,11 +65,12 @@ module.exports = (robot) ->
|
|||||||
'va bene, mi hai stancato. vattene ma non dire niente a diliberti']
|
'va bene, mi hai stancato. vattene ma non dire niente a diliberti']
|
||||||
user = res.message.user.name.toLowerCase().split '_'
|
user = res.message.user.name.toLowerCase().split '_'
|
||||||
mem = robot.brain.get 'internati' or {}
|
mem = robot.brain.get 'internati' or {}
|
||||||
vals = user.map (x) -> lev.get name, x for name of mem
|
dists = ([(Math.min.apply @, user.map (x) -> lev.get name, x), name] for name of mem)
|
||||||
if (Math.min.apply @, [].concat.apply([], vals)) < 4
|
[dist, name] = dists.reduce (x, y) -> if x[0] < y[0] then x else y
|
||||||
|
if dist < 4
|
||||||
if Math.random() < 0.02
|
if Math.random() < 0.02
|
||||||
res.send res.random ok
|
res.send res.random ok
|
||||||
delete mem[user.join '_']
|
delete mem[name]
|
||||||
robot.brain.set 'internati', mem
|
robot.brain.set 'internati', mem
|
||||||
else
|
else
|
||||||
res.send res.random nope
|
res.send res.random nope
|
||||||
|
Loading…
Reference in New Issue
Block a user