The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-lib/lib/slashCommand.coffee

26 lines
755 B

RocketChat.slashCommands =
commands: {}
RocketChat.slashCommands.add = (command, callback, options) ->
RocketChat.slashCommands.commands[command] =
command: command
callback: callback
params: options?.params
description: options?.description
clientOnly: options?.clientOnly or false
return
RocketChat.slashCommands.run = (command, params, item) ->
if RocketChat.slashCommands.commands[command]?.callback?
callback = RocketChat.slashCommands.commands[command].callback
callback command, params, item
Meteor.methods
slashCommand: (command) ->
if not Meteor.userId()
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'slashCommand' }
RocketChat.slashCommands.run command.cmd, command.params, command.msg