This repository has been archived by the owner on Feb 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add netfault tolerance, allow sever scrub (#1)
* Add netfault tolerance * Rejoin channel on reconnect * Change error messages * Sleep after nick change * Catch InterruptedException
- Loading branch information
1 parent
4d70feb
commit 3076a0a
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
package org.iuscsg.ccdclogger; | ||
import org.jibble.pircbot.*; | ||
|
||
public class IRCBotl extends PircBot{ | ||
public class IRCBotl extends PircBot { | ||
private boolean exit = false; | ||
public IRCBotl() { | ||
this.setName("Logger-" + (int) (Math.random() * 500)); | ||
} | ||
protected void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason) | ||
{ | ||
if (recipientNick.equals(this.getNick())) | ||
{ | ||
System.out.println("Bot was kicked from #events! Rejoining right away"); | ||
this.joinChannel("#events"); | ||
} | ||
} | ||
|
||
public void setExit(boolean status) | ||
{ | ||
exit = status; | ||
} | ||
|
||
protected void onDisconnect() | ||
{ | ||
if (!exit) | ||
{ | ||
System.out.println("Connection lost! Reconnecting right away"); | ||
try | ||
{ | ||
this.reconnect(); | ||
this.joinChannel("#events"); | ||
} catch (Exception e) { | ||
System.out.println("Failed to reconnect. Exiting..."); | ||
System.exit(2); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters