-
Notifications
You must be signed in to change notification settings - Fork 73
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
A single message can trigger multiple responses #64
Comments
@wasnotrice can you show me your regexes for your The way the responders work is completely async. Each incoming message is dispatched to all responders. If a message matches a responder it will be run. |
@scrogson here's an example set of hear/respond invocations with regexes: hear ~r/let (.*) know/, message do
sendRandomKnowledge message
end
respond ~r/let (.*) know/, message do
replyOrEmoteRandomly message
end As you see, the regexes are the same. I guess my confusion comes from the fact that I don't expect the I don't think I articulated the issue well initially. You're right, of course, the responders are async so it doesn't make sense to talk about "if no Am I thinking about it all wrong? |
@wasnotrice re-writing your hear ~r/^let (.*) know/i, msg do
send_random_knowledge msg
end That would ensure that it would only respond if the message begins with In any case, I guess I would need to see where other use-cases might really require a different implementation than I currently have. |
@scrogson hmmmmm, I see how anchoring the regex would filter out direct messages, so that is a workaround. But it would also mean that I can't match a message like I could write a much more complicated regex that filtered out only messages starting with my bot's name/alias, but I'm looking for the framework to provide a macro for that, rather than having to code the regex for individual responders. If FWIW, I am porting these responders from a Hubot bot, where they work as I expect (i.e. the Thanks! |
Gotcha. I will work on a solution. Thanks. |
@scrogson thanks! happy to pitch in and/or draft something if its helpful :) |
Hi, thanks for Hedwig. I've learned a lot from it already :)
I have a bot that I want to respond to both overheard and direct messages of the same kind, but respond differently to direct messages. For example:
If I add both a
hear
and arespond
handler that match the same message shape, then for direct messages, both handlers are triggered, which feels weird in the chat:Ideally, in this case, I'd like Hedwig to only execute the
respond
handler. Maybe it makes sense to execute thehear
handler if norespond
handler matches, but maybe it makes sense to only considerhear
handlers for overheard messages.I'd be happy to pursue this if it seems like a good change. Cheers!
The text was updated successfully, but these errors were encountered: