Ejemplo n.º 1
1
			_id: Random.id(),
			rid,
			ts: new Date,
			msg: TAPi18n.__('Username_doesnt_exist', {
				postProcess: 'sprintf',
				sprintf: [username],
			}, user.language),
		});
	}

	const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, user._id, { fields: { _id: 1 } });
	if (!subscription) {
		return RocketChat.Notifications.notifyUser(userId, 'message', {
			_id: Random.id(),
			rid,
			ts: new Date,
			msg: TAPi18n.__('Username_is_not_in_this_room', {
				postProcess: 'sprintf',
				sprintf: [username],
			}, user.language),
		});
	}
	Meteor.call('removeUserFromRoom', { rid, username });
};

RocketChat.slashCommands.add('kick', Kick, {
	description: 'Remove_someone_from_room',
	params: '@username',
	permission: 'remove-user',
});
Ejemplo n.º 2
0
		Meteor.runAsUser(user._id, () => {
			result = RocketChat.slashCommands.run(cmd, params, {
				_id: Random.id(),
				rid: body.roomId,
				msg: `/${ cmd } ${ params }`,
			});
		});
Ejemplo n.º 3
0
}, function(err, result, params) {
	if (err.error === 'error-user-already-in-room') {
		params.cmd = 'open';
		params.msg.msg = params.msg.msg.replace('join', 'open');
		return RocketChat.slashCommands.run('open', params.params, params.msg);
	}
});
Ejemplo n.º 4
0
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
/*
* Tableflip is a named function that will replace /Tableflip commands
* @param {Object} message - The message object
*/


function Tableflip(command, params, item) {
	if (command === 'tableflip') {
		const msg = item;
		msg.msg = `${ params } (╯°□°)╯︵ ┻━┻`;
		Meteor.call('sendMessage', msg);
	}
}

RocketChat.slashCommands.add('tableflip', Tableflip, {
	description: 'Slash_Tableflip_Description',
	params: 'your_message_optional',
});
Ejemplo n.º 5
0
RocketChat.slashCommands.add('unmute', function Unmute(command, params, item) {

	if (command !== 'unmute' || !Match.test(params, String)) {
		return;
	}
	const username = params.trim().replace('@', '');
	if (username === '') {
		return;
	}
	const user = Meteor.users.findOne(Meteor.userId());
	const unmutedUser = RocketChat.models.Users.findOneByUsername(username);
	if (unmutedUser == null) {
		return RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
			_id: Random.id(),
			rid: item.rid,
			ts: new Date,
			msg: TAPi18n.__('Username_doesnt_exist', {
				postProcess: 'sprintf',
				sprintf: [username],
			}, user.language),
		});
	}

	const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(item.rid, unmutedUser._id, { fields: { _id: 1 } });
	if (!subscription) {
		return RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
			_id: Random.id(),
			rid: item.rid,
			ts: new Date,
			msg: TAPi18n.__('Username_is_not_in_this_room', {
				postProcess: 'sprintf',
				sprintf: [username],
			}, user.language),
		});
	}
	Meteor.call('unmuteUserInRoom', {
		rid: item.rid,
		username,
	});
}, {
	description: 'Unmute_someone_in_room',
	params: '@username',
});
Ejemplo n.º 6
0
	}
	const message = trimmedParams.slice(separator + 1);
	const targetUsernameOrig = trimmedParams.slice(0, separator);
	const targetUsername = targetUsernameOrig.replace('@', '');
	const targetUser = RocketChat.models.Users.findOneByUsername(targetUsername);
	if (targetUser == null) {
		RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
			_id: Random.id(),
			rid: item.rid,
			ts: new Date,
			msg: TAPi18n.__('Username_doesnt_exist', {
				postProcess: 'sprintf',
				sprintf: [targetUsernameOrig],
			}, user.language),
		});
		return;
	}
	const { rid } = Meteor.call('createDirectMessage', targetUsername);
	const msgObject = {
		_id: Random.id(),
		rid,
		msg: message,
	};
	Meteor.call('sendMessage', msgObject);
}

RocketChat.slashCommands.add('msg', Msg, {
	description: 'Direct_message_someone',
	params: '@username <message>',
});
			} else {
				msgStream.emit(item.rid, {
					_id: Random.id(),
					rid: item.rid,
					u: { username: '******' },
					ts: new Date(),
					msg: TAPi18n.__('SlackBridge_finish', {
						postProcess: 'sprintf',
						sprintf: [channel],
					}, user.language),
				});
			}
		});
	} catch (error) {
		msgStream.emit(item.rid, {
			_id: Random.id(),
			rid: item.rid,
			u: { username: '******' },
			ts: new Date(),
			msg: TAPi18n.__('SlackBridge_error', {
				postProcess: 'sprintf',
				sprintf: [channel, error.message],
			}, user.language),
		});
		throw error;
	}
	return SlackBridgeImport;
}

RocketChat.slashCommands.add('slackbridge-import', SlackBridgeImport);
Ejemplo n.º 8
0
					users,
				});
			}
			return RocketChat.Notifications.notifyUser(userId, 'message', {
				_id: Random.id(),
				rid: item.rid,
				ts: new Date(),
				msg: TAPi18n.__('Users_added', null, currentUser.language),
			});
		} catch (e) {
			const msg = e.error === 'cant-invite-for-direct-room' ? 'Cannot_invite_users_to_direct_rooms' : e.error;
			RocketChat.Notifications.notifyUser(userId, 'message', {
				_id: Random.id(),
				rid: item.rid,
				ts: new Date(),
				msg: TAPi18n.__(msg, null, currentUser.language),
			});
		}
	};
}

RocketChat.slashCommands.add('invite-all-to', inviteAll('to'), {
	description: 'Invite_user_to_join_channel_all_to',
	params: '#room',
});
RocketChat.slashCommands.add('invite-all-from', inviteAll('from'), {
	description: 'Invite_user_to_join_channel_all_from',
	params: '#room',
});
module.exports = inviteAll;
Ejemplo n.º 9
0
			rid: item.rid,
			ts: new Date(),
			msg: TAPi18n.__('Channel_already_Unarchived', {
				postProcess: 'sprintf',
				sprintf: [channel],
			}, user.language),
		});
		return;
	}

	Meteor.call('unarchiveRoom', room._id);

	RocketChat.models.Messages.createRoomUnarchivedByRoomIdAndUser(room._id, Meteor.user());
	RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
		_id: Random.id(),
		rid: item.rid,
		ts: new Date(),
		msg: TAPi18n.__('Channel_Unarchived', {
			postProcess: 'sprintf',
			sprintf: [channel],
		}, user.language),
	});

	return Unarchive;
}

RocketChat.slashCommands.add('unarchive', Unarchive, {
	description: 'Unarchive',
	params: '#channel',
});
Ejemplo n.º 10
0
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.slashCommands.add('join', undefined, {
	description: 'Join_the_given_channel',
	params: '#channel',
}, function(err, result, params) {
	if (err.error === 'error-user-already-in-room') {
		params.cmd = 'open';
		params.msg.msg = params.msg.msg.replace('join', 'open');
		return RocketChat.slashCommands.run('open', params.params, params.msg);
	}
});
Ejemplo n.º 11
0
		try {
			return Meteor.call('addUserToRoom', {
				rid: item.rid,
				username: user.username,
			});
		} catch ({ error }) {
			if (error === 'cant-invite-for-direct-room') {
				RocketChat.Notifications.notifyUser(userId, 'message', {
					_id: Random.id(),
					rid: item.rid,
					ts: new Date,
					msg: TAPi18n.__('Cannot_invite_users_to_direct_rooms', null, currentUser.language),
				});
			} else {
				RocketChat.Notifications.notifyUser(userId, 'message', {
					_id: Random.id(),
					rid: item.rid,
					ts: new Date,
					msg: TAPi18n.__(error, null, currentUser.language),
				});
			}
		}
	});
}

RocketChat.slashCommands.add('invite', Invite, {
	description: 'Invite_user_to_join_channel',
	params: '@username',
});
Ejemplo n.º 12
-1
			});
		}

		if (!RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(room._id, user._id, { fields: { _id: 1 } })) {
			return RocketChat.Notifications.notifyUser(user._id, 'message', {
				_id: Random.id(),
				rid: item.rid,
				ts: new Date,
				msg: TAPi18n.__('error-logged-user-not-in-room', {
					postProcess: 'sprintf',
					sprintf: [room],
				}, user.language),
			});
		}
		rid = roomObject._id;
	}

	Meteor.call('hideRoom', rid, (error) => {
		if (error) {
			return RocketChat.Notifications.notifyUser(user._id, 'message', {
				_id: Random.id(),
				rid: item.rid,
				ts: new Date,
				msg: TAPi18n.__(error, null, user.language),
			});
		}
	});
}

RocketChat.slashCommands.add('hide', Hide, { description: 'Hide_room', params: '#room' });