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
Provide Hubot the ability to react to message types #349
Conversation
I like the idea of being able to do things with other kinds of messages. I'm not sure about the public api, ie calling the method In addition to that, I'd like to see some examples of this in the README.rdoc and/or the method documentation for see. |
I decided to go with see as opposed to respond since respond seems to be used for messages directed at the robot itself. I needed the ability to react to specific message types (regardless of how they are directed) within the Campfire room, so I felt adding a new method was the proper approach. Happy to provide additional docs (I will be pushing an example plugin to hubot-scripts once this is merged). Would you prefer a new section of the README be created or would perhaps putting this kind of documentation in a wiki page be better? |
Let's go with an updated section to the README. That way, the docs get updated with the merge. |
Ok, added some stuff to the README under a new section called Robot Functionality. I went ahead and documented the other robot functions as well. The Campfire adapter additions I feel would be better served being put on the wiki page. I'll add the example for how to change the topic as well as a link to the GH page regarding the room info API once this is merged. |
A couple of functions calls had stray commas in there.
Fix typos in README
Been thinking about this a bit more. I'm still not feeling the 'see' API as far as language goes, and plus it feels like it's expose too many internals for scripts to use/abuse. If you are interested in topic stuff specifically, I rather see a topic listener, rather an this It should be pretty simple to implement this in # Public: Adds a Listener that triggers when anyone changes the topic
#
# callback - A Function that is called with a Response object.
#
# Returns nothing.
topic: (callback) ->
@listeners.push new Listener(@, ((msg) -> msg instanceof TopicMessage), callback) This would depend on some of the work already done. Thoughts? |
I'm ok with removing
over this:
I do have one worry: is |
@wingrunr21 there's been a number of changes in master preparing for 3.0. Mind taking a stab at merging master so this will merge cleanly? |
Sure, do you have feedback on my last comment? |
IRC and Jabber both have topics for their rooms, so it's applicable there. It'd be up to the adapter maintainer to implement though. |
👍 |
Sorry this has been left in the wind by me. I have carved out time on Friday to get this updated against the latest master and implement the changes @technicalpickles asked for. |
Sorry I dropped the ball on that again. Thanks @tombell! |
I tried merging the PR, but there were too many conflicts so I recreated the branch, based on the changes you had done, with some minor fixes which make it a bit more consistent. For example: module.exports = (robot) ->
robot.topic (msg) ->
robot.send "Oh dear #{msg.user} changed the topic to #{msg.message}" (note I forgot what the actual properties on |
I needed the ability for hubot to react to topic changes in Campfire as well as the ability to query the Campfire room for information (like the current topic).
I made changes that allow hubot to "see" a message. The function will allow a String, Regex, or actual object name to be specified as what to watch for:
The enter and leave events have been updated to use this common way of reacting to message types.
I also added an info utility function to the Campfire adaptor. It is possible I missed something more obvious for using it, but here is what I am currently using:
I'm working on an example script for this stuff to commit to hubot-scripts