Fixed connexion exception retry (#5261).

This commit is contained in:
Christian P. MOMON 2021-04-13 04:23:31 +02:00
parent 9a3bf64417
commit 03e346554f

View File

@ -400,6 +400,7 @@ public class Hebdobot extends PircBot
*/ */
public void run() throws HebdobotException public void run() throws HebdobotException
{ {
//
try try
{ {
logger.info("Cron initializing."); logger.info("Cron initializing.");
@ -408,46 +409,59 @@ public class Hebdobot extends PircBot
this.cronManager.start(); this.cronManager.start();
} }
logger.info("Cron initialized."); logger.info("Cron initialized.");
logger.info("Bot connection.");
this.connect(this.host, this.port);
logger.info("Bot connected.");
if (this.identifyPassword == null)
{
logger.info("Skipped identify.");
}
else
{
logger.info("Apply identify.");
sendMessage("NickServ", "identify " + this.identifyNick + " " + this.identifyPassword);
logger.info("Applied identify.");
}
logger.info("Bot joining channel ({}).", this.channel);
this.joinChannel(this.channel);
logger.info("Bot ready.");
} }
catch (NickAlreadyInUseException exception) catch (SchedulerException | ParseException exception)
{
throw new HebdobotException(exception);
}
catch (IOException exception)
{
throw new HebdobotException(exception);
}
catch (IrcException exception)
{
throw new HebdobotException(exception);
}
catch (SchedulerException exception)
{ {
throw new HebdobotException("Error in cron settings.", exception); throw new HebdobotException("Error in cron settings.", exception);
} }
catch (ParseException exception)
// Manage "Caused by: java.net.UnknownHostException: irc.freenode.org".
boolean ended = false;
while (!ended)
{ {
throw new HebdobotException(exception); try
{
logger.info("Bot connection.");
this.connect(this.host, this.port);
logger.info("Bot connected.");
ended = true;
}
catch (NickAlreadyInUseException exception)
{
throw new HebdobotException(exception);
}
catch (IOException exception)
{
try
{
Thread.sleep(60000);
}
catch (InterruptedException subException)
{
subException.printStackTrace();
}
}
catch (IrcException exception)
{
throw new HebdobotException(exception);
}
} }
//
if (this.identifyPassword == null)
{
logger.info("Skipped identify.");
}
else
{
logger.info("Apply identify.");
sendMessage("NickServ", "identify " + this.identifyNick + " " + this.identifyPassword);
logger.info("Applied identify.");
}
logger.info("Bot joining channel ({}).", this.channel);
this.joinChannel(this.channel);
logger.info("Bot ready.");
} }
/** /**