I've upgraded my hubot-slack to the latest version and noticed the new changes including SlackBotMessage, but I'm confused on how to use it from my script. I guess I do not understand what slack.coffee l.117 does:
@receive new SlackBotMessage user, text, rawText, msg
This is different from robot.emit isn't it? In the later, I simply need to run robot.on to get the message, but from your case, how should I do ?
example of wanted script:
robot.hear /WORD/i, (res) ->
robot.brain.set 'bot_message', res.message.text
will use robot.catchAll until I find a better way
I have same problem...
Also want a solution to this
Anybody else figure out the proper implementation of this? I'm having difficulty importing the extension into my coffeescript, and I'd really love to utilize this implementation.
@kballard any chance you could provide some insight on how to implement the SlackBotListener. I'm trying to have an Ansible playbook call our hubot on slack to perform some final tasks on creating a vagrant on deploy (i.e. cert signing, etc.), but hubot continually ignores all bot_message types...even those that directly callout to our hubot.
Thanks!
+1
+1
+1
+1
Hi all. Not sure why it's so hard to get some docs for this, but I found this post:
http://www.bunkei-programmer.net/entry/2016/02/16/014621 :jp: :fireworks:
TL;DR:
HubotSlack = require 'hubot-slack'
module.exports = (robot) ->
regex = /^(Failed:|Timed out:).*/
robot.listeners.push new HubotSlack.SlackBotListener robot, regex, (msg) ->
msg.send "blah"
I think this only listens for bot messages, so someone will have to figure out how to listen for regular messages as well.
Interesting, will look into what it would take to make this feasible.
@MrMMorris this trick doesn't seem to work with newer versions of hubot-slack (not sure when it broke exactly). Now getting a TypeError: HubotSlack.SlackBotListener is not a constructor
Yeah this probably broke in commit 900402ea254b0fdf5a819fd3073325c68f1692a9.
Have you tried listening to all events and then filtering to the specific data you are interested in (channel, user, message, etc)?
I recently did this to listen to when users join to specific channels and then send them DM with some rules and links.
robot.adapter.client.on('raw_message', raw_message => {
console.log(raw_message);
});
thanks for the tip @eruizdechavez! in addition, you can write a custom listener as shown in the hubot docs here: https://hubot.github.com/docs/scripting/#custom-listeners.
from my reading of the code as it is now, this should no longer be an issue because both messages from users and bots are classified as TextMessages, for which robot.hear should work. if that's not the case, please let me know and i can reopen the issue.