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] Add reaction to the last message when get the shortcut +: #7569

Merged
merged 11 commits into from
Jul 27, 2017

Conversation

danilomiranda
Copy link
Contributor

@RocketChat/core
Closes #3756

reaction

@RocketChat RocketChat deleted a comment Jul 25, 2017
@RocketChat RocketChat deleted a comment Jul 25, 2017
@RocketChat RocketChat deleted a comment Jul 25, 2017
@RocketChat RocketChat deleted a comment Jul 25, 2017
@RocketChat RocketChat deleted a comment Jul 25, 2017
@@ -192,6 +192,7 @@ Template.messagePopup.onCreated(function() {
return;
}
const value = template.input.value;
const preColon = value.substr(0, value.indexOf(':'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? Why not just use trigger: '\\+:'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to this b/c when we select one emoji the string of the emoji replace the string on input-message. In this case, we need to keep the + caracter before the first :

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use:

trigger: '\\+:',
prefix: '+'

Did you try?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, no. I'll try that thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rodrigok work like a charm 👌

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-7569 July 25, 2017 15:47 Inactive
danilomiranda and others added 3 commits July 25, 2017 14:46
I haven't notice that we can insert a prefix and/or suffix in the final
string on config, thanks @rodrigok 🚀
@rodrigok rodrigok added this to the 0.58.0 milestone Jul 25, 2017
@@ -182,6 +182,12 @@ this.ChatMessages = class ChatMessages {

const msg = input.value;
const msgObject = { _id: Random.id(), rid, msg};
const lastMessage = ChatMessage.findOne({rid}, { fields: { ts: 1 }, sort: { ts: -1 }});
if (msg[0]+msg[1] === '+:') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use msg.slice(0, 2) instead of msg[0]+msg[1] and check if the emoji exists first:

const reaction = msg.slice(1).trim();
if (RocketChat.emoji.list[reaction]) {
...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you try you can set a reaction with an invalid emoji like +:as: askjhdak

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!
How can we trigger an sound error when trying to send a wrong command?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not trigger a sound, just send the message, maybe the users is trying to send that as a message

@rodrigok rodrigok merged commit 5ce9e7e into RocketChat:develop Jul 27, 2017
@ramses2000
Copy link

ramses2000 commented Aug 24, 2017

Not working with hubot. Hubot send message as text, not reaction.

        robot.hear /goat/i, (res) ->
                res.emote "+:goat:"

capture

But if user send "+:goat:", then reaction is set:

capture2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants