parent
6324e2bf04
commit
9682c27e68
@ -0,0 +1,3 @@ |
||||
RocketChat.slashCommands.add 'invite', undefined, |
||||
description: TAPi18n.__ 'Invite_user_to_join_channel' |
||||
params: '@username' |
@ -0,0 +1,3 @@ |
||||
RocketChat.slashCommands.add 'join', undefined, |
||||
description: TAPi18n.__ 'Join_the_given_channel' |
||||
params: '#channel' |
@ -1,36 +0,0 @@ |
||||
### |
||||
# 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: TAPi18n.__ 'Join_the_given_channel' |
||||
params: '#channel' |
||||
else |
||||
class Join |
||||
constructor: (command, params, item) -> |
||||
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 = RocketChat.models.Rooms.findOneByNameAndTypeNotContainigUsername(channel, 'c', user.username) |
||||
|
||||
if not room? |
||||
RocketChat.Notifications.notifyUser Meteor.userId(), 'message', { |
||||
_id: Random.id() |
||||
rid: item.rid |
||||
ts: new Date |
||||
msg: TAPi18n.__('Channel_doesnt_exist', { postProcess: 'sprintf', sprintf: [ channel ] }, user.language); |
||||
} |
||||
return |
||||
|
||||
Meteor.call 'joinRoom', room._id |
||||
|
||||
RocketChat.slashCommands.add 'join', Join |
@ -0,0 +1,31 @@ |
||||
### |
||||
# Join is a named function that will replace /join commands |
||||
# @param {Object} message - The message object |
||||
### |
||||
|
||||
class Join |
||||
constructor: (command, params, item) -> |
||||
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 = RocketChat.models.Rooms.findOneByNameAndTypeNotContainigUsername(channel, 'c', user.username) |
||||
|
||||
if not room? |
||||
RocketChat.Notifications.notifyUser Meteor.userId(), 'message', { |
||||
_id: Random.id() |
||||
rid: item.rid |
||||
ts: new Date |
||||
msg: TAPi18n.__('Channel_doesnt_exist', { postProcess: 'sprintf', sprintf: [ channel ] }, user.language); |
||||
} |
||||
return |
||||
|
||||
Meteor.call 'joinRoom', room._id |
||||
|
||||
RocketChat.slashCommands.add 'join', Join |
Loading…
Reference in new issue