-
Notifications
You must be signed in to change notification settings - Fork 27
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
How to run custom code at bot startup? #123
Comments
Currently there are not an easy way of dealing with this, but I'll add an optional |
that'd be great, thanks! |
The problem I found with I suggest |
@manuel-rubio What's the use case for needing the If you are trying to link a bot with Phoenix.PubSub in order to receive broadcast messages, I don't think subscribing from the dispatcher is a good thing. I would definitely go with my own Supervisor, with the Bot and a GenServer to handle the subscription, then the GenServer can send messages to the bot manually (Either with |
I did it in that way, but it's weird to have a GenServer only for sending messages to another process. defmodule MyProject.Bot.Proxy do
use GenServer
def init([]) do
Phoenix.PubSub.subscribe(MyProject.PubSub, "topic1")
{:ok, nil}
end
def handle_info(info, nil) do
send(MyProject.Bot.name(), info)
{:ok, nil}
end
end It's not providing value at all and it's needed only because I cannot run startup code inside of the Dispatcher process. My problem with that is I put in the |
I'd like to run
set_my_command
,set_my_description
,set_my_name
and some other initialization code at bot startup. What's the best way to do it?Thanks!
The text was updated successfully, but these errors were encountered: