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

posting to multiple rooms #3601

Closed
IQ2022 opened this issue Jun 21, 2016 · 5 comments
Closed

posting to multiple rooms #3601

IQ2022 opened this issue Jun 21, 2016 · 5 comments

Comments

@IQ2022
Copy link

IQ2022 commented Jun 21, 2016

Is there a way to add a command or a feature that when someone types a message can automatically sent to another channel for records?
example :
am in general room and i decided to take a trade
"buy 1000 $AAPL" + command
this message will be copied to a different room called #trades
vs me copying that message over?

does it make sense :)
Your Rocket.Chat version:0.34

@lucasvanhalst
Copy link
Contributor

I'm fairly sure you could create a hubot script that would do this
Similar to this: RocketChat/hubot-rocketchat#126 (comment)
but instead of updateMessage you would have to call sendMessage (see https://github.com/RocketChat/Rocket.Chat/blob/f90c48b5c1fbee48a39a506b3985d758e1ecb90b/packages/rocketchat-lib/server/methods/sendMessage.coffee)

You can have the bot listen to 'buy [number] [symbol]' and send it to a particular room if a message matches this requirement

@IQ2022
Copy link
Author

IQ2022 commented Jun 22, 2016

wish there is step by step on how to do that?

@lucasvanhalst
Copy link
Contributor

lucasvanhalst commented Jun 22, 2016

Well you could start by deploying a hubot and linking it to your rocket.chat server.

If you're willing to use docker it's easy, copy paste this file in some directory on your server (preferable somewhere in /opt or so) and call it docker-compose.yml: https://gist.github.com/lucasvanhalst/7c4b2cd563fccae822d221caa3217b15 (this is mainly copied from here https://github.com/RocketChat/Rocket.Chat/blob/develop/docker-compose.yml)
adjust the parameters as necessary (ROCKETCHAT_USER could be 'bot' for example, this is an account you have to create and it will be used to post as the bot)
Create a folder in the directory where you placed your docker-compose.yml file called 'data' and in that folder another one called 'hubot-scripts'. In this last folder you can place any custom scripts you like and they will be added to the hubot when you start it

Execute the command docker-compose up hubot and it should be up and running.

The script itself could look something like this (call it `hubot-respond-to-buy.js' or something like that and place it in the data/hubot-scripts folder):

module.exports = function (robot) {
        function sendMessage(newMessage) {
                return robot.adapter.callMethod('sendMessage', {
                        rid: 'room-id-where-the-message-should-go',
                        msg: newMessage
                })["catch"](function (err) {
                        return console.error(err);
                });
        }

        robot.hear(/buy ([0-9]+) (.*)/ig, function (msg) {
                var newMessage, amount , symbol;
                amount = msg.match[1];
                symbol = msg.match[2]
                newMessage = msg.message.user + ' wants to buy ' + amount + ' of ' + symbol;
                sendMessage(newMessage);
        });
};

You should replace room-id-where-the-message-should-go with the actual room id. Unfortunately you can't view it easily, only by using inspect element in the browser or in the database directly.
To test you could put GENERAL as room id as every rocket.chat instance has a room with this id unless you've deleted it.

@MartinSchoeler
Copy link
Contributor

This would be a very nice feature, but unfortunately it does not align with our current roadmap, so it's probable that it would not be implemented in the near future. I will be closing this issue for now, if we plan to add a feature like this we will reopen this issue. Thanks for the valuable feedback!

@timkinnane
Copy link
Contributor

Added this as a proposal on #10174

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

No branches or pull requests

4 participants