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

[NEW] Internal hubot support for Direct Messages and Private Groups #8933

Merged
3 changes: 3 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,9 @@
"InternalHubot_ScriptsToLoad": "Scripts to Load",
"InternalHubot_ScriptsToLoad_Description": "Please enter a comma separated list of scripts to load from your custom folder",
"InternalHubot_Username_Description": "This must be a valid username of a bot registered on your server.",
"InternalHubot_EnableForChannels": "Enable for Public Channels",
"InternalHubot_EnableForDirectMessages": "Enable for Direct Messages",
"InternalHubot_EnableForPrivateGroups": "Enable for Private Channels",
"Invalid_confirm_pass": "The password confirmation does not match password",
"Invalid_email": "The email entered is invalid",
"Invalid_Export_File": "The file uploaded isn't a valid %s export file.",
Expand Down
10 changes: 9 additions & 1 deletion packages/rocketchat-internal-hubot/hubot.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,16 @@ const InternalHubotReceiver = (message) => {
if (DEBUG) { console.log(message); }
if (message.u.username !== InternalHubot.name) {
const room = RocketChat.models.Rooms.findOneById(message.rid);
const enabledForC = RocketChat.settings.get('InternalHubot_EnableForChannels');
const enabledForD = RocketChat.settings.get('InternalHubot_EnableForDirectMessages');
const enabledForP = RocketChat.settings.get('InternalHubot_EnableForPrivateGroups');
const subscribedToP = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(room._id, InternalHubot.user._id);

if (room.t === 'c') {
if (
(room.t === 'c' && enabledForC)
|| (room.t === 'd' && enabledForD)
|| (room.t === 'p' && enabledForP && subscribedToP)
) {
const InternalHubotUser = new Hubot.User(message.u.username, {room: message.rid});
const InternalHubotTextMessage = new Hubot.TextMessage(InternalHubotUser, message.msg, message._id);
InternalHubot.adapter.receive(InternalHubotTextMessage);
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-internal-hubot/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ RocketChat.settings.addGroup('InternalHubot', function() {
this.add('InternalHubot_Username', 'rocket.cat', { type: 'string', i18nLabel: 'Username', i18nDescription: 'InternalHubot_Username_Description', 'public': true });
this.add('InternalHubot_ScriptsToLoad', '', { type: 'string'});
this.add('InternalHubot_PathToLoadCustomScripts', '', { type: 'string' });
this.add('InternalHubot_EnableForChannels', true, { type: 'boolean' });
this.add('InternalHubot_EnableForDirectMessages', false, { type: 'boolean' });
this.add('InternalHubot_EnableForPrivateGroups', false, { type: 'boolean' });
// this.add('InternalHubot_reload', 'reloadInternalHubot', {
// type: 'action',
// actionText: 'reload'
Expand Down