当他能够向Hubot提供正确的密码时,我想为用户添加新角色.
这是我现在的脚本:
module.exports = (robot) ->
robot.respond /PasswOrd (.*)/, (res) ->
paSS = res.match[1]
if paSS is "1234"
role = 'h1'
user = robot.brain.userForName(res.message.user.name)
#CODE TO ADD ROLE h1 FOR THIS USER ???
res.reply "Correct." + user.id
else
res.reply "Incorrect password."
Run Code Online (Sandbox Code Playgroud)
它正确启动 @bot PasswOrd 1234
但我不知道如何添加角色.
谢谢.