Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added the slash command /create - to create a new channel #3585

Merged
merged 4 commits into from
Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ todda00:friendly-slugs
underscorestring:underscore.string
yasaricli:slugify
yasinuslu:blaze-meta
rocketchat:slashcommands-create
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ rocketchat:push-notifications@0.0.1
rocketchat:reactions@0.0.1
rocketchat:slackbridge@0.0.1
rocketchat:slashcommands-asciiarts@0.0.1
rocketchat:slashcommands-create@0.0.1
rocketchat:slashcommands-invite@0.0.1
rocketchat:slashcommands-join@0.0.1
rocketchat:slashcommands-kick@0.0.1
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-lib/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
"Changing_email" : "Changing email",
"Channel" : "Channel",
"Channel_doesnt_exist" : "The channel `#%s` does not exist.",
"Channel_already_exist" : "The channel '#%s' already exists.",
"Channels" : "Channels",
"Channels_list" : "List of public channels",
"Chat_button" : "Chat button",
Expand Down Expand Up @@ -247,6 +248,7 @@
"Cozy" : "Cozy",
"Create" : "Create",
"Create_new" : "Create new",
"Create_A_New_Channel" : "Create a New Channel",
"Created_at" : "Created at",
"Created_at_s_by_s" : "Created at <strong>%s</strong> by <strong>%s</strong>",
"Current_Chats" : "Current Chats",
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-slashcommands-create/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RocketChat.slashCommands.add('create', null, {
description: TAPi18n.__('Create_A_New_Channel'),
params: 'channel'
});
22 changes: 22 additions & 0 deletions packages/rocketchat-slashcommands-create/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Package.describe({
name: 'rocketchat:slashcommands-create',
version: '0.0.1',
summary: 'Command handler for the /create command',
git: ''
});

Package.onUse(function(api) {

api.versionsFrom('1.0');

api.use([
'ecmascript',
'check',
'rocketchat:lib'
]);

api.use('templating', 'client');

api.addFiles('client.js', 'client');
api.addFiles('server.js', 'server');
});
28 changes: 28 additions & 0 deletions packages/rocketchat-slashcommands-create/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function Create(command, params, item) {
var channel, room, user;
if (command !== 'create' || !Match.test(params, String)) {
return;
}
channel = params.trim();
if (channel === '') {
return;
}

user = Meteor.users.findOne(Meteor.userId());
room = RocketChat.models.Rooms.findOneByName(channel);
if (room != null) {
RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
_id: Random.id(),
rid: item.rid,
ts: new Date(),
msg: TAPi18n.__('Channel_already_exist', {
postProcess: 'sprintf',
sprintf: [channel]
}, user.language)
});
return;
}
Meteor.call('createChannel', channel, []);
}

RocketChat.slashCommands.add('create', Create);