Skip to content

Only first bot connects when multiple are configured #19

@natempv

Description

@natempv

Hi! I've followed the configuration and guide, and when I have one bot it works splendidly, we've had all sorts of fun with it, but when I have multiple bot_configs it appears that only the first one connects and relays messages. I've tried with the same account, different accounts, different channels, and whatever the first one to connect is succeeds while the rest do not.

In my Application.ex:

    ...

    children = [

      ...

      {PartitionSupervisor, child_spec: DynamicSupervisor, name: MyApp.DynamicSupervisors}
    ]

    ...

    # Add the running ones
    running_bots = MyApp.Context.Bot.get_all_running!()

    bot_configs =
      for bot <- running_bots do
        # TMI bot config
        [
          bot: MyApp.Twitchbot,
          user: bot.twitch_user,
          pass: bot.twitch_pass,
          channels: [bot.twitch_channel],
          mod_channels: [""],
          capabilities: ["membership", "tags", "commands"],
          debug: false
        ]
      end


    for {bot_config, index} <- Enum.with_index(bot_configs) do
      # give TMIs to supervisors
      DynamicSupervisor.start_child(
        {:via, PartitionSupervisor, {MyApp.DynamicSupervisors, index}},
        {TMI.Supervisor, bot_config}
      )
    end

    ...

In Twitchbot.ex:

defmodule MyApp.Twitchbot do
  use TMI

  @impl TMI.Handler

  def handle_message(message, sender, chat) do
    Logger.debug("Message in #{chat} from #{sender}: #{message}")
  end
end

...

I get Logger messages from the first bot to connect, and nothing else.

Snipped for relevance and also to remove a perhaps gratuitous amount of IO.inspect calls. Just trying to figure out what I've got set up incorrectly here, or what my fundamental misunderstanding is 😅

Thank you for your wonderful library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions