Connecting to multiple IRC servers with ExIrc (Elixir)?

I would like to connect to two servers in ExIrc using elixir, and I cannot find an easy solution for this. I'm new to elixir, and all I can see is that I can use umbrellas to launch two applications and interact with them with each other? (I would like to use one application to connect to one IRC server, and if it has some specific words, analyze the data and send it to another IRC server)

+5
source share
1 answer

So, to connect one client, you can do something like:

ExIrc.start! {:ok, client} = ExIrc.Client.start_link {:ok, handler} = ExampleHandler.start_link(nil) ExIrc.Client.add_handler(client, handler) ExIrc.Client.connect!(client, "chat.freenode.net", 6667) 

I use ExampleHandler in the same way as README suggests. Now, if you do something like:

 pass = "" nick = "my_nick" ExIrc.Client.logon(client, pass, nick, nick, nick) ExIrc.Client.join(client, "#elixir-lang") 

You will begin to look at the messages from #elixir-lang that will be displayed on the console - as ExampleHandler is implemented, you will probably implement something else in its place.

Now nothing is stopping you from doing this a second time:

 {:ok, client2} = ExIrc.Client.start_link {:ok, handler2} = ExampleHandler.start_link(nil) # and so on 

To create a client2 client that is connected to the same or different server. To achieve what you want, you just need to write a handler that responds to messages from the client by calling ExIrc.Client.msg(client2, ...) to publish to another client.

+2
source

All Articles