mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-26 02:42:16 -05:00
Bugfix: Only automatically change nickname on server code 433 if not already registered with server
This commit is contained in:
parent
aa5a081c02
commit
dd07bd358a
@ -139,6 +139,7 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
* @throws NickAlreadyInUseException if our nick is already in use on the server.
|
* @throws NickAlreadyInUseException if our nick is already in use on the server.
|
||||||
*/
|
*/
|
||||||
public final synchronized void connect(String hostname, int port, String password) throws IOException, IrcException, NickAlreadyInUseException {
|
public final synchronized void connect(String hostname, int port, String password) throws IOException, IrcException, NickAlreadyInUseException {
|
||||||
|
_registered = false;
|
||||||
|
|
||||||
_server = hostname;
|
_server = hostname;
|
||||||
_port = port;
|
_port = port;
|
||||||
@ -876,7 +877,7 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
String errorStr = token;
|
String errorStr = token;
|
||||||
String response = line.substring(line.indexOf(errorStr, senderInfo.length()) + 4, line.length());
|
String response = line.substring(line.indexOf(errorStr, senderInfo.length()) + 4, line.length());
|
||||||
|
|
||||||
if (code == 433) {
|
if (code == 433 && !_registered) {
|
||||||
if (_autoNickChange) {
|
if (_autoNickChange) {
|
||||||
List<String> aliases = getAliases();
|
List<String> aliases = getAliases();
|
||||||
_autoNickTries++;
|
_autoNickTries++;
|
||||||
@ -1068,6 +1069,17 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
*/
|
*/
|
||||||
protected void onConnect() {}
|
protected void onConnect() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called once the client is registered with the server -
|
||||||
|
* meaning the client recieved server code 004.
|
||||||
|
*
|
||||||
|
* @since Yaaic
|
||||||
|
*/
|
||||||
|
protected void onRegister()
|
||||||
|
{
|
||||||
|
_registered = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method carries out the actions to be performed when the PircBot
|
* This method carries out the actions to be performed when the PircBot
|
||||||
@ -1087,7 +1099,10 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
* The implementation of this method in the PircBot abstract class
|
* The implementation of this method in the PircBot abstract class
|
||||||
* performs no actions and may be overridden as required.
|
* performs no actions and may be overridden as required.
|
||||||
*/
|
*/
|
||||||
protected void onDisconnect() {}
|
protected void onDisconnect()
|
||||||
|
{
|
||||||
|
_registered = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2460,6 +2475,18 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
return _inputThread != null && _inputThread.isConnected();
|
return _inputThread != null && _inputThread.isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns wether or not the client is registered with the server.
|
||||||
|
*
|
||||||
|
* @since Yaaic
|
||||||
|
*
|
||||||
|
* @return True if server code 004 has been received. False otherwise.
|
||||||
|
*/
|
||||||
|
public final synchronized boolean isRegistered()
|
||||||
|
{
|
||||||
|
return _registered;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the number of milliseconds to delay between consecutive
|
* Sets the number of milliseconds to delay between consecutive
|
||||||
@ -3082,6 +3109,7 @@ public abstract class PircBot implements ReplyConstants {
|
|||||||
private boolean _autoNickChange = false;
|
private boolean _autoNickChange = false;
|
||||||
private int _autoNickTries = 1;
|
private int _autoNickTries = 1;
|
||||||
private boolean _useSSL = false;
|
private boolean _useSSL = false;
|
||||||
|
private boolean _registered = false;
|
||||||
|
|
||||||
private String _name = "PircBot";
|
private String _name = "PircBot";
|
||||||
private final List<String> _aliases = new ArrayList<String>();
|
private final List<String> _aliases = new ArrayList<String>();
|
||||||
|
@ -160,8 +160,12 @@ public class IRCConnection extends PircBot
|
|||||||
/**
|
/**
|
||||||
* On register
|
* On register
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onRegister()
|
public void onRegister()
|
||||||
{
|
{
|
||||||
|
// Call parent method to ensure "register" status is tracked
|
||||||
|
super.onRegister();
|
||||||
|
|
||||||
// execute commands
|
// execute commands
|
||||||
CommandParser parser = CommandParser.getInstance();
|
CommandParser parser = CommandParser.getInstance();
|
||||||
|
|
||||||
@ -1047,6 +1051,9 @@ public class IRCConnection extends PircBot
|
|||||||
@Override
|
@Override
|
||||||
public void onDisconnect()
|
public void onDisconnect()
|
||||||
{
|
{
|
||||||
|
// Call parent method to ensure "register" status is tracked
|
||||||
|
super.onDisconnect();
|
||||||
|
|
||||||
if (service.getSettings().isReconnectEnabled() && server.getStatus() != Status.DISCONNECTED) {
|
if (service.getSettings().isReconnectEnabled() && server.getStatus() != Status.DISCONNECTED) {
|
||||||
setAutojoinChannels(server.getCurrentChannelNames());
|
setAutojoinChannels(server.getCurrentChannelNames());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user