Compare commits
No commits in common. "c7e29120457ac8a11c344e2a0fb72d315faccc48" and "4340038a91506a42c468f1b6e91f7c53c30cab3c" have entirely different histories.
c7e2912045
...
4340038a91
4 changed files with 32 additions and 31 deletions
|
@ -85,7 +85,7 @@ public class CTCPHelper {
|
||||||
if (notFoundMessage == null)
|
if (notFoundMessage == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//System.out.println(serverReplied + " PRIVMSG " + channelOrUser + " :" + notFoundMessage + whoNotFound);
|
System.out.println(serverReplied + " PRIVMSG " + channelOrUser + " :" + notFoundMessage + whoNotFound);
|
||||||
StreamProvider.writeToStream(serverReplied, "PRIVMSG " + channelOrUser + " :" + notFoundMessage + whoNotFound);
|
StreamProvider.writeToStream(serverReplied, "PRIVMSG " + channelOrUser + " :" + notFoundMessage + whoNotFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,12 @@ public class StreamProvider {
|
||||||
|
|
||||||
public static synchronized void writeToStream(String server, String message){
|
public static synchronized void writeToStream(String server, String message){
|
||||||
try {
|
try {
|
||||||
|
if (message.matches("(^.+?\\s)INNA")) {
|
||||||
|
SystemConsumer.getSystemConsumer(server).add("INNA "+message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
srvStreamMap.get(server).write(message+"\n");
|
srvStreamMap.get(server).write(message+"\n");
|
||||||
srvStreamMap.get(server).flush();
|
srvStreamMap.get(server).flush();
|
||||||
if (message.startsWith("PRIVMSG")) {
|
|
||||||
SystemConsumer.getSystemConsumer(server).add("INNA "+message);
|
|
||||||
}
|
|
||||||
} catch (IOException e){
|
} catch (IOException e){
|
||||||
System.out.println("Internal issue: StreamProvider->writeToStream() caused I/O exception:\n\t"+e.getMessage());
|
System.out.println("Internal issue: StreamProvider->writeToStream() caused I/O exception:\n\t"+e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,18 +66,8 @@ public class SystemConsumer implements Runnable{
|
||||||
String data = systemQueue.take();
|
String data = systemQueue.take();
|
||||||
String[] dataStrings = data.split(" :?",3);
|
String[] dataStrings = data.split(" :?",3);
|
||||||
//TODO: handle mode change
|
//TODO: handle mode change
|
||||||
|
switch (dataStrings[1]){
|
||||||
if (dataStrings[0].equals("INNA")){
|
case "PRIVMSG":
|
||||||
String[] splitter;
|
|
||||||
if (dataStrings.length > 2){ // Don't touch 'cuz it's important
|
|
||||||
splitter = dataStrings[2].split(" ", 2);
|
|
||||||
if (splitter.length == 2){
|
|
||||||
handleSpecial(dataStrings[1], splitter[0], splitter[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ("PRIVMSG".equals(dataStrings[1])) {
|
|
||||||
if (dataStrings[2].indexOf("\u0001") < dataStrings[2].lastIndexOf("\u0001")) {
|
if (dataStrings[2].indexOf("\u0001") < dataStrings[2].lastIndexOf("\u0001")) {
|
||||||
String sender = simplifyNick(dataStrings[0]);
|
String sender = simplifyNick(dataStrings[0]);
|
||||||
String message = dataStrings[2].substring(dataStrings[2].indexOf(":") + 1);
|
String message = dataStrings[2].substring(dataStrings[2].indexOf(":") + 1);
|
||||||
|
@ -87,8 +77,17 @@ public class SystemConsumer implements Runnable{
|
||||||
commander.receiver(dataStrings[0], dataStrings[2].replaceAll("^.+?:", "").trim());
|
commander.receiver(dataStrings[0], dataStrings[2].replaceAll("^.+?:", "").trim());
|
||||||
writerWorker.log(dataStrings[1]+" "+dataStrings[0]+" :", dataStrings[2].replaceAll("^.+?:", "").trim());
|
writerWorker.log(dataStrings[1]+" "+dataStrings[0]+" :", dataStrings[2].replaceAll("^.+?:", "").trim());
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case "INNA":
|
||||||
|
String[] splitter;
|
||||||
|
if (dataStrings.length > 2){ // Don't touch 'cuz it's important
|
||||||
|
splitter = dataStrings[2].split(" ", 2);
|
||||||
|
if (splitter.length == 2){
|
||||||
|
handleSpecial(dataStrings[0], splitter[0], splitter[1]);
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
handleNumeric(dataStrings[0], dataStrings[1], dataStrings[2]);
|
handleNumeric(dataStrings[0], dataStrings[1], dataStrings[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +107,8 @@ public class SystemConsumer implements Runnable{
|
||||||
IrcChannel ircChannel = channels.get(channelName);
|
IrcChannel ircChannel = channels.get(channelName);
|
||||||
if (ircChannel == null)
|
if (ircChannel == null)
|
||||||
return;
|
return;
|
||||||
String ircFormatterMessage = nick+" "+event+" "+channelName+" "+message;
|
String ircFormatterMessage = event+" "+nick+" "+channelName+" "+message;
|
||||||
|
|
||||||
ircChannel.getChannelQueue().add(ircFormatterMessage);
|
ircChannel.getChannelQueue().add(ircFormatterMessage);
|
||||||
}
|
}
|
||||||
//todo: handle nickserv messages somehow
|
//todo: handle nickserv messages somehow
|
||||||
|
@ -123,7 +123,7 @@ public class SystemConsumer implements Runnable{
|
||||||
+ " [nickname already in use and will be changed]");
|
+ " [nickname already in use and will be changed]");
|
||||||
break;
|
break;
|
||||||
case "353":
|
case "353":
|
||||||
writerWorker.log("handled:", eventNum+" [RPL_NAMREPLY]");
|
writerWorker.log("catch/handled:", eventNum+" [RPL_NAMREPLY]");
|
||||||
String channelName = message.substring(nick.length()+3).replaceAll("\\s.*$", "");
|
String channelName = message.substring(nick.length()+3).replaceAll("\\s.*$", "");
|
||||||
|
|
||||||
IrcChannel ircChannel = channels.get(channelName);
|
IrcChannel ircChannel = channels.get(channelName);
|
||||||
|
@ -151,7 +151,7 @@ public class SystemConsumer implements Runnable{
|
||||||
Thread newIrcChannelThread = new Thread(consumer);
|
Thread newIrcChannelThread = new Thread(consumer);
|
||||||
newIrcChannelThread.start();
|
newIrcChannelThread.start();
|
||||||
channelThreads.add(newIrcChannelThread);
|
channelThreads.add(newIrcChannelThread);
|
||||||
newIrcChannel.getChannelQueue().add(sender+" "+eventNum+" "+message);
|
//proxyAList.get(message).add(eventNum+" "+sender+" "+message); // Add message to array linked
|
||||||
writerWorker.log("joined channel ", message);
|
writerWorker.log("joined channel ", message);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class WorkerSystem{
|
||||||
if (consistent)
|
if (consistent)
|
||||||
logToFile(message);
|
logToFile(message);
|
||||||
else
|
else
|
||||||
System.out.print(message);
|
System.out.println(message);
|
||||||
}
|
}
|
||||||
private void logToFile(String message){
|
private void logToFile(String message){
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue