mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-29 04:12:18 -05:00
PircBot Patch: Recognize "%" as a nickname prefix
This commit is contained in:
parent
cf5ea6049c
commit
c35e1fc1ab
@ -11,7 +11,7 @@ found at http://www.jibble.org/licenses/
|
||||
|
||||
Modified by: Sebastian Kaspari <sebastian@yaaic.org>
|
||||
|
||||
*/
|
||||
*/
|
||||
package org.jibble.pircbot;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -225,8 +225,8 @@ public abstract class PircBot implements ReplyConstants {
|
||||
tries++;
|
||||
nick = ((tries - 1) <= aliases.size()) ?
|
||||
aliases.get(tries - 2) :
|
||||
getName() + (tries - aliases.size());
|
||||
OutputThread.sendRawLine(this, bwriter, "NICK " + nick);
|
||||
getName() + (tries - aliases.size());
|
||||
OutputThread.sendRawLine(this, bwriter, "NICK " + nick);
|
||||
}
|
||||
else {
|
||||
socket.close();
|
||||
@ -757,6 +757,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
*
|
||||
* @deprecated As of PircBot 1.2.0, use {@link #onIncomingFileTransfer(DccFileTransfer)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected final void dccReceiveFile(File file, long address, int port, int size) {
|
||||
throw new RuntimeException("dccReceiveFile is deprecated, please use sendFile");
|
||||
}
|
||||
@ -846,6 +847,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
*
|
||||
* @deprecated As of PircBot 1.2.0, use {@link #onIncomingChatRequest(DccChat)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected final DccChat dccAcceptChatRequest(String sourceNick, long address, int port) {
|
||||
throw new RuntimeException("dccAcceptChatRequest is deprecated, please use onIncomingChatRequest");
|
||||
}
|
||||
@ -1149,7 +1151,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
// Stick with the default value of zero.
|
||||
}
|
||||
|
||||
String topic = (String) _topics.get(channel);
|
||||
String topic = _topics.get(channel);
|
||||
_topics.remove(channel);
|
||||
|
||||
this.onTopic(channel, topic, setBy, date, false);
|
||||
@ -1175,6 +1177,10 @@ public abstract class PircBot implements ReplyConstants {
|
||||
// Some wibbly status I've never seen before...
|
||||
prefix = ".";
|
||||
}
|
||||
// XXX: PircBot Patch - Recognize % as prefix - Often used as "half-operator" prefix
|
||||
else if (nick.startsWith("%")) {
|
||||
prefix = "%";
|
||||
}
|
||||
nick = nick.substring(prefix.length());
|
||||
this.addUser(channel, new User(prefix, nick));
|
||||
}
|
||||
@ -1401,6 +1407,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
*
|
||||
* @deprecated As of 1.2.0, replaced by {@link #onTopic(String,String,String,long,boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected void onTopic(String channel, String topic) {}
|
||||
|
||||
|
||||
@ -1483,26 +1490,26 @@ public abstract class PircBot implements ReplyConstants {
|
||||
pn = atPos;
|
||||
}
|
||||
else if (atPos == 'o') {
|
||||
if (pn == '+') {
|
||||
this.updateUser(channel, OP_ADD, params[p]);
|
||||
onOp(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
|
||||
}
|
||||
else {
|
||||
this.updateUser(channel, OP_REMOVE, params[p]);
|
||||
onDeop(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
else if (atPos == 'v') {
|
||||
if (pn == '+') {
|
||||
this.updateUser(channel, VOICE_ADD, params[p]);
|
||||
onVoice(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
|
||||
}
|
||||
else {
|
||||
this.updateUser(channel, VOICE_REMOVE, params[p]);
|
||||
onDeVoice(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
|
||||
}
|
||||
p++;
|
||||
if (pn == '+') {
|
||||
this.updateUser(channel, OP_ADD, params[p]);
|
||||
onOp(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
|
||||
}
|
||||
else {
|
||||
this.updateUser(channel, OP_REMOVE, params[p]);
|
||||
onDeop(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
else if (atPos == 'v') {
|
||||
if (pn == '+') {
|
||||
this.updateUser(channel, VOICE_ADD, params[p]);
|
||||
onVoice(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
|
||||
}
|
||||
else {
|
||||
this.updateUser(channel, VOICE_REMOVE, params[p]);
|
||||
onDeVoice(channel, sourceNick, sourceLogin, sourceHostname, params[p]);
|
||||
}
|
||||
p++;
|
||||
}
|
||||
else if (atPos == 'k') {
|
||||
if (pn == '+') {
|
||||
@ -2096,6 +2103,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
*
|
||||
* @deprecated As of PircBot 1.2.0, use {@link #onIncomingFileTransfer(DccFileTransfer)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected void onDccSendRequest(String sourceNick, String sourceLogin, String sourceHostname, String filename, long address, int port, int size) {}
|
||||
|
||||
|
||||
@ -2106,6 +2114,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
*
|
||||
* @deprecated As of PircBot 1.2.0, use {@link #onIncomingChatRequest(DccChat)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected void onDccChatRequest(String sourceNick, String sourceLogin, String sourceHostname, long address, int port) {}
|
||||
|
||||
|
||||
@ -2709,7 +2718,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
return null;
|
||||
}
|
||||
// Clone the array to prevent external modification.
|
||||
return (int[]) _dccPorts.clone();
|
||||
return _dccPorts.clone();
|
||||
}
|
||||
|
||||
|
||||
@ -2733,7 +2742,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
}
|
||||
else {
|
||||
// Clone the array to prevent external modification.
|
||||
_dccPorts = (int[]) ports.clone();
|
||||
_dccPorts = ports.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2747,6 +2756,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
*
|
||||
* @return true if and only if Object o is a PircBot and equal to this.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
// This probably has the same effect as Object.equals, but that may change...
|
||||
if (o instanceof PircBot) {
|
||||
@ -2766,6 +2776,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
*
|
||||
* @return the hash code for this instance of PircBot.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
@ -2790,12 +2801,13 @@ public abstract class PircBot implements ReplyConstants {
|
||||
*
|
||||
* @return a String representation of this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Version{" + _version + "}" +
|
||||
" Connected{" + isConnected() + "}" +
|
||||
" Server{" + _server + "}" +
|
||||
" Port{" + _port + "}" +
|
||||
" Password{" + _password + "}";
|
||||
" Connected{" + isConnected() + "}" +
|
||||
" Server{" + _server + "}" +
|
||||
" Port{" + _port + "}" +
|
||||
" Password{" + _password + "}";
|
||||
}
|
||||
|
||||
|
||||
@ -2838,7 +2850,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
userArray = new User[users.size()];
|
||||
Enumeration<User> enumeration = users.elements();
|
||||
for (int i = 0; i < userArray.length; i++) {
|
||||
User user = (User) enumeration.nextElement();
|
||||
User user = enumeration.nextElement();
|
||||
userArray[i] = user;
|
||||
}
|
||||
}
|
||||
@ -2865,7 +2877,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
channels = new String[_channels.size()];
|
||||
Enumeration<String> enumeration = _channels.keys();
|
||||
for (int i = 0; i < channels.length; i++) {
|
||||
channels[i] = (String) enumeration.nextElement();
|
||||
channels[i] = enumeration.nextElement();
|
||||
}
|
||||
}
|
||||
return channels;
|
||||
@ -2924,7 +2936,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
synchronized (_channels) {
|
||||
Hashtable<User, User> users = _channels.get(channel);
|
||||
if (users != null) {
|
||||
return (User) users.remove(user);
|
||||
return users.remove(user);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -2938,7 +2950,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
synchronized (_channels) {
|
||||
Enumeration<String> enumeration = _channels.keys();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
String channel = (String) enumeration.nextElement();
|
||||
String channel = enumeration.nextElement();
|
||||
this.removeUser(channel, nick);
|
||||
}
|
||||
}
|
||||
@ -2952,7 +2964,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
synchronized (_channels) {
|
||||
Enumeration<String> enumeration = _channels.keys();
|
||||
while (enumeration.hasMoreElements()) {
|
||||
String channel = (String) enumeration.nextElement();
|
||||
String channel = enumeration.nextElement();
|
||||
User user = this.removeUser(channel, oldNick);
|
||||
if (user != null) {
|
||||
user = new User(user.getPrefix(), newNick);
|
||||
@ -2992,7 +3004,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
if (users != null) {
|
||||
Enumeration<User> enumeration = users.elements();
|
||||
while(enumeration.hasMoreElements()) {
|
||||
User userObj = (User) enumeration.nextElement();
|
||||
User userObj = enumeration.nextElement();
|
||||
if (userObj.getNick().equalsIgnoreCase(nick)) {
|
||||
if (userMode == OP_ADD) {
|
||||
if (userObj.hasVoice()) {
|
||||
@ -3053,7 +3065,7 @@ public abstract class PircBot implements ReplyConstants {
|
||||
private String _password = null;
|
||||
|
||||
// Outgoing message stuff.
|
||||
private Queue _outQueue = new Queue();
|
||||
private final Queue _outQueue = new Queue();
|
||||
private long _messageDelay = 1000;
|
||||
|
||||
// A Hashtable of channels that points to a selfreferential Hashtable of
|
||||
@ -3062,10 +3074,10 @@ public abstract class PircBot implements ReplyConstants {
|
||||
|
||||
// A Hashtable to temporarily store channel topics when we join them
|
||||
// until we find out who set that topic.
|
||||
private Hashtable<String, String> _topics = new Hashtable<String, String>();
|
||||
private final Hashtable<String, String> _topics = new Hashtable<String, String>();
|
||||
|
||||
// DccManager to process and handle all DCC events.
|
||||
private DccManager _dccManager = new DccManager(this);
|
||||
private final DccManager _dccManager = new DccManager(this);
|
||||
private int[] _dccPorts = null;
|
||||
private InetAddress _dccInetAddress = null;
|
||||
|
||||
@ -3074,11 +3086,11 @@ public abstract class PircBot implements ReplyConstants {
|
||||
private boolean _useSSL = false;
|
||||
|
||||
private String _name = "PircBot";
|
||||
private List<String> _aliases = new ArrayList<String>();
|
||||
private final List<String> _aliases = new ArrayList<String>();
|
||||
private String _nick = _name;
|
||||
private String _login = "PircBot";
|
||||
private String _version = "PircBot " + VERSION + " Java IRC Bot - www.jibble.org";
|
||||
private String _finger = "You ought to be arrested for fingering a bot!";
|
||||
|
||||
private String _channelPrefixes = "#&+!";
|
||||
private final String _channelPrefixes = "#&+!";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user