-
Notifications
You must be signed in to change notification settings - Fork 28
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
Possible to send a message without having Message struct? #39
Comments
Hey there :) I'm not 100% sure I understand the question completely but I guess you want to emit your own custom events? If that is true you can find general instructions for how to do that here: https://joe-bot.net/basics/events/ and To get a better understanding of the event system you should check out https://joe-bot.net/recipes/events Let me know if the documentation answers your question or if we should improve the documentation in that area a little :) |
After a bit more reading I figured out what I need to do. I was defining functions like By following the pattern outlined on the site and attaching methods to the Bot receiver (if I'm using the terminology correctly), I can easily send an arbitrary message through the adapter: My solution looks like: func (b *Bot) HandleDoorbell(ctx context.Context, evt joehttp.RequestEvent) error {
if evt.URL.Path == "/doorbell" {
b.Adapter.Send("Someone is at the door!", "#general")
}
return nil
} Regarding documentation - the notes that you've included in the recipe guides are great in isolation, but I found that I was searching for a complete example of how to link all of these 'best practices' together. Is there an example/starter template where this kind of code lives? If desired, I could help sketch out an example bot of how to put all of these pieces together. |
I'm glad you found a solution. For your small code snipped I want to point you at func (b *Bot) HandleDoorbell(ctx context.Context, evt joehttp.RequestEvent) error {
if evt.URL.Path == "/doorbell" {
b.Say("#general", "Someone is at the door!")
}
return nil
} It depends on the adapter implementation if you can pass channel names like this (i.e. About the "receiver" terminology, that actually comes from Go and means the receiver in a function definition which is the instance that a function is called upon 🤓 The examples provided are all a bit minimal but all of them should be fully executable (i.e. they have a Even better would be an example that is actually deployed somewhere and does something. In that sense I would be happy to link to existing implementations that people put together and open sourced. Another approach could be to create a bot that is used by this repository, e.g. to great new people that submit an issue (e.g. https://github.com/go-joe/github-bot). Apart from greeting people I don't really have an idea though what else it could do. What are your thoughts on this? :) |
I found I put together a more thorough example to try to explain the issues I'm dealing with that would be helpful in a complete example. I think a separate repo is appropriate for a 'full example', and maybe even a 'ready to use' Slack example is also appropriate, where it could show basic custom functionality. As an aside, but related, there are two things that I'm struggling with at this time:
Any feedback you can provide on how I might structure the code to address these issues would be appreciated, then once I have these things sorted out this might serve as a starting point for what code in an example repo could look like. |
Thanks for putting together this library, I'm just starting to explore it.
I was wondering if there is a recommended method to send an arbitrary message to a channel without needing to "Respond" to a message that has come in.
My [first] use case is that I want to send a message to a channel after receiving a webhook via the http-server.
I suppose one way that I might be able to achieve this is to have the webhook handler publish a
joe.ReceiveMessageEvent
event with the desired channel that I want tosend
a message to, then listen for this 'silent' event emitted and respond to it. This will likely work, but it seems like quite a workaround to achieve my goal.Any insight you can provide would be appreciated.
Thanks
The text was updated successfully, but these errors were encountered: