visciang / telegram

Telegram library for the Elixir language
MIT License
204 stars 27 forks source link

bad child specification, more than one child specification has the id: Telegram.Bot.ChatBot.Chat.Supervisor #160

Closed samm81 closed 11 months ago

samm81 commented 11 months ago

hello, I'm back :)

I am getting the following error:

** (Mix) Could not start application my_app: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: Telegram.Poller
    ** (EXIT) bad child specification, more than one child specification has the id: Telegram.Bot.ChatBot.Chat.Supervisor.

my Application :

defmodule MyApp.Application do
  use Application

  alias MyApp.TelegramBot

  @tg_bot_token_bot1 Application.compile_env!(:zuo_shou, :tg_bot_token_bot1)
  @tg_bot_token_bot2 Application.compile_env!(:zuo_shou, :tg_bot_token_bot2)

  @impl true
  def start(_type, _args) do
    bots = [
      {TelegramBot.Bot1, bot_config(@tg_bot_token_bot1)},
      {TelegramBot.Bot2, bot_config(@tg_bot_token_bot2)}
    ]

    children = [{Telegram.Poller, bots: bots}]

    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)
  end

  @spec bot_config(String.t()) :: Keyword.t()
  defp bot_config(token), do: [token: token, max_bot_concurrency: 1]
end

I've double checked and the two tokens are definitely different (IO.inspect({@tg_bot_token_bot1, @tg_bot_token_bot2})), so the issue is not the same as #153

visciang commented 11 months ago

Hello @samm81, Fix available in release 1.1.1

samm81 commented 11 months ago

amazing :clap: fastest I've ever seen an issue fixed. thank you!