v0.5.2 rolling: refactoring.
This commit is contained in:
parent
301cf74470
commit
157a38cf79
3 changed files with 16 additions and 22 deletions
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>loper</groupId>
|
<groupId>loper</groupId>
|
||||||
<artifactId>InnaIrcBot</artifactId>
|
<artifactId>InnaIrcBot</artifactId>
|
||||||
<version>0.5.1-SNAPSHOT</version>
|
<version>0.5.2-SNAPSHOT</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>InnaIrcBot</name>
|
<name>InnaIrcBot</name>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package InnaIrcBot;
|
package InnaIrcBot;
|
||||||
|
|
||||||
public class GlobalData {
|
public class GlobalData {
|
||||||
private static final String version = "InnaIrcBot v0.5.1 \"Шикотан\"";
|
private static final String version = "InnaIrcBot v0.5.2 \"Шикотан\"";
|
||||||
public static synchronized String getAppVersion(){
|
public static synchronized String getAppVersion(){
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,21 +75,19 @@ public class SystemConsumer implements Runnable{
|
||||||
if (getProxy(dataStrings[0], dataStrings[1], dataStrings[2]))
|
if (getProxy(dataStrings[0], dataStrings[1], dataStrings[2]))
|
||||||
continue; // TODO: check this. Continue is fair?
|
continue; // TODO: check this. Continue is fair?
|
||||||
|
|
||||||
if (dataStrings[0].equals("PRIVMSG") && dataStrings[2].indexOf("\u0001") < dataStrings[2].lastIndexOf("\u0001")) {
|
if (Pattern.matches("(^[0-9]{3}$)|(^NICK$)|(^JOIN$)|(^QUIT$)|(^NOTICE$)", dataStrings[0])){
|
||||||
replyCTCP(simplifyNick(dataStrings[1]), dataStrings[2].substring(dataStrings[2].indexOf(":") + 1));
|
|
||||||
//System.out.println("|"+dataStrings[1]+"|"+dataStrings[2].substring(dataStrings[2].indexOf(":") + 1)+"|");
|
|
||||||
}
|
|
||||||
else if (Pattern.matches("(^[0-9]{3}$)|(^NICK$)|(^JOIN$)|(^QUIT$)", dataStrings[0])){
|
|
||||||
handleNumeric(dataStrings[0], dataStrings[1], dataStrings[2]);
|
handleNumeric(dataStrings[0], dataStrings[1], dataStrings[2]);
|
||||||
}
|
}
|
||||||
else if (dataStrings[0].equals("PRIVMSG")) {
|
else if (dataStrings[0].equals("PRIVMSG")) {
|
||||||
commander.receiver(dataStrings[1], dataStrings[2].replaceAll("^.+?:", "").trim());
|
if (dataStrings[2].indexOf("\u0001") < dataStrings[2].lastIndexOf("\u0001")) {
|
||||||
writerWorker.logAdd("[system]", "PRIVMSG from "+dataStrings[1]+" received: ", dataStrings[2].replaceAll("^.+?:", "").trim());
|
replyCTCP(simplifyNick(dataStrings[1]), dataStrings[2].substring(dataStrings[2].indexOf(":") + 1));
|
||||||
|
//System.out.println("|"+dataStrings[1]+"|"+dataStrings[2].substring(dataStrings[2].indexOf(":") + 1)+"|");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
commander.receiver(dataStrings[1], dataStrings[2].replaceAll("^.+?:", "").trim());
|
||||||
|
writerWorker.logAdd("[system]", "PRIVMSG from "+dataStrings[1]+" received: ", dataStrings[2].replaceAll("^.+?:", "").trim());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (dataStrings[0].equals("NOTICE")) {
|
|
||||||
handleNotice(dataStrings[1], dataStrings[2].replaceAll("^.+?:", "").trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (dataStrings[0].equals("INNA")) {
|
else if (dataStrings[0].equals("INNA")) {
|
||||||
String[] splitter;
|
String[] splitter;
|
||||||
if (dataStrings.length > 2){ // Don't touch 'cuz it's important
|
if (dataStrings.length > 2){ // Don't touch 'cuz it's important
|
||||||
|
@ -163,11 +161,6 @@ public class SystemConsumer implements Runnable{
|
||||||
|
|
||||||
private String simplifyNick(String nick){ return nick.replaceAll("!.*$",""); }
|
private String simplifyNick(String nick){ return nick.replaceAll("!.*$",""); }
|
||||||
|
|
||||||
private void handleNotice(String sender, String message){
|
|
||||||
writerWorker.logAdd("[system]", "NOTICE from "+sender+" received: ", message);
|
|
||||||
CTCPHelper.getInstance().handleCtcpReply(serverName, simplifyNick(sender), message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleSpecial(String event, String chanel, String message){
|
private void handleSpecial(String event, String chanel, String message){
|
||||||
//System.out.println("|"+event+"|"+chanel+"|"+message+"|");
|
//System.out.println("|"+event+"|"+chanel+"|"+message+"|");
|
||||||
if (channelsMap.containsKey(chanel)){
|
if (channelsMap.containsKey(chanel)){
|
||||||
|
@ -239,13 +232,14 @@ public class SystemConsumer implements Runnable{
|
||||||
CTCPHelper.getInstance().handleErrorReply(serverName, message.replaceAll("^(\\s)?.+?(\\s)|((\\s)?:No such nick/channel)",""));
|
CTCPHelper.getInstance().handleErrorReply(serverName, message.replaceAll("^(\\s)?.+?(\\s)|((\\s)?:No such nick/channel)",""));
|
||||||
writerWorker.logAdd("[system]", "catch: "+eventNum+" from: "+sender+" :",message+" [ok]");
|
writerWorker.logAdd("[system]", "catch: "+eventNum+" from: "+sender+" :",message+" [ok]");
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case "NOTICE":
|
case "NOTICE":
|
||||||
writerWorker.logAdd("[system]", eventNum+" from: "+sender+" received: ",message);
|
CTCPHelper.getInstance().handleCtcpReply(serverName, simplifyNick(sender), message.replaceAll("^.+?:", "").trim());
|
||||||
|
writerWorker.logAdd("[system]", "NOTICE from "+sender+" received: ", message.replaceAll("^.+?:", "").trim());
|
||||||
|
break;
|
||||||
|
case "QUIT":
|
||||||
break;
|
break;
|
||||||
*/
|
|
||||||
default:
|
default:
|
||||||
writerWorker.logAdd("[system]", "catch: "+eventNum+" from: "+sender+" :",message); // TODO: QUIT comes here. Do something.
|
writerWorker.logAdd("[system]", "catch: "+eventNum+" from: "+sender+" :",message); // TODO: QUIT comes here. Do something?
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue