Skip to content
Snippets Groups Projects
Commit 3819168f authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Merge pull request #789 from graywolf336/join-command

Add the join command
parents 397ae6bc d34d8b62
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ rocketchat:me
rocketchat:mentions
rocketchat:oembed
rocketchat:slashcommands-invite
rocketchat:slashcommands-join
rocketchat:slashcommands-leave
rocketchat:statistics
rocketchat:webrtc
......
......@@ -116,6 +116,7 @@ rocketchat:me@0.0.1
rocketchat:mentions@0.0.1
rocketchat:oembed@0.0.1
rocketchat:slashcommands-invite@0.0.1
rocketchat:slashcommands-join@0.0.1
rocketchat:slashcommands-leave@0.0.1
rocketchat:statistics@0.0.1
rocketchat:webrtc@0.0.1
......
###
# Join is a named function that will replace /join commands
# @param {Object} message - The message object
###
if Meteor.isClient
RocketChat.slashCommands.add 'join', undefined,
description: 'Join the given channel'
params: '#channel'
else
class Join
constructor: (command, params) ->
if command isnt 'join' or not Match.test params, String
return
channel = params.trim()
if channel is ''
return
channel = channel.replace('#', '')
user = Meteor.users.findOne Meteor.userId()
room = ChatRoom.findOne({ name: channel, t: 'c', usernames: { $nin: [ user.username ]} })
if not room?
return
Meteor.call 'joinRoom', room._id
RocketChat.slashCommands.add 'join', Join
Package.describe({
name: 'rocketchat:slashcommands-join',
version: '0.0.1',
summary: 'Command handler for the /join command',
git: ''
});
Package.onUse(function(api) {
api.versionsFrom('1.0');
api.use([
'coffeescript',
'check',
'rocketchat:lib@0.0.1'
]);
api.addFiles('join.coffee');
});
Package.onTest(function(api) {
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment