I posted to Slack via ROS Subscriber. As usual, we do not consider demand.
You can easily connect to Slack using SlackClient.
pip install slackclient
Put the Slack Web API library in pip. (What should I do with ROS as a virtual environment?)
I'm posting to Slack with a Subscriber callback. Channels and user names may be parameterized.
sc.py
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
from slackclient import SlackClient
token = "TOKEN" #Token is https://api.slack.com/Make on the web
username = "ros"
channel = "#ros"
sc = SlackClient(token)
def callback(message):
print sc.api_call("chat.postMessage", channel=channel, text=message.data, username=username)
rospy.init_node("rosslack")
sub = rospy.Subscriber("postMessage", String, callback)
rospy.spin()
chmod +x sc.py
./sc.py
Publish using rostopic
from another console.
rostopic pub /postMessage std_msgs/String -- 'hoge'
Now, if you look at the Slack screen, you should see a message from ROS.
Recommended Posts