From 5c22f699531a27019735656d9e52250be1478c7f Mon Sep 17 00:00:00 2001 From: "Rachel Fae Fox (foxiepaws)" Date: Fri, 17 Jul 2020 14:18:09 -0400 Subject: [PATCH] basic reconnection logic --- lib/irc_bot.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/irc_bot.ex b/lib/irc_bot.ex index 34bac12..0f7780a 100644 --- a/lib/irc_bot.ex +++ b/lib/irc_bot.ex @@ -114,6 +114,16 @@ defmodule Discordirc.IRC do {:noreply, state} end + def handle_info(:disconnected, state) do + if state.ssl? do + Client.connect_ssl!(state.client, state.server, state.port) + else + Client.connect!(state.client, state.server, state.port) + end + + {:noreply, state} + end + def handle_info(_event, state) do {:noreply, state} end