This functionality was added to newer versions of rocketchat, this same way WILL work, but it’s easier to do it in the room interface.
We switched from a paid slack account last year, to rocketchat.
I’ve written bots in the past to alert coworkers of system issues in a more public place, but some of my rooms were getting upwards of 10,000 messages and the browser and phones would be extremely slow pulling the room up as message counts were growing.
Sending messages to a chat in a controlled manor is a great way to alert a lot of people to issues, or log something. This should make it super easy to clean the rooms out when they grow larger than you thought they would!
python to the rescue!
My client can do the following:
- test connection to server (–whoami)
- send a message to a user. (–send –user justin –text “hi there!”)
- send a message to a group. (–send –group groupname –text “Hi there!”)
- send a message to a channel. (–send –channel channelname –text “Hi there!”
- delete all messages in a group. (–delete –group roomname –iknow)
- delete all messages in a channel. (–delete –channel roomname –iknow)
- install saved rocketchat credentials. (–install –rcuser user –rcpass pass –rchost hostname)
- spam a group with test messages (–trash –iknow –group groupname)
- spam a channel with test messages (–trash –iknow –channel channelname)
What are these groups and channels?
On rocketchat it gets a little confusing sometimes. If you have a room, where everyone is allowed to view and post, it’s considered a “channel”.
If you have a private channel, it’s considered a “group”.
I found a newer api, as my last client was using rocket-python, which didnt seem to allow me to delete messages in a somewhat controlled manor.
The api can be installed like so
to use the software paste the following in a file, name it rc-client.py
you might want to install python3:
it’s in the repo for centos, and fedora, and pretty much any operating system, since I use rpm based distros, these instructions are for CentOS.
once saved, use the following examples:
first install example:
delete messages from channel:
delete messages from room:
send a message to a group:
send a message to a channel:
send a message to a user:
fill a channel with test messages:
file a group with test messages: