This commit is contained in:
Dmitry Isaenko 2020-11-01 20:25:03 +03:00
parent 4340038a91
commit d6ccf25775
2 changed files with 27 additions and 28 deletions

View file

@ -12,12 +12,11 @@ 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());
} }

View file

@ -66,29 +66,30 @@ 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]){
case "PRIVMSG": if (dataStrings[0].equals("INNA")){
if (dataStrings[2].indexOf("\u0001") < dataStrings[2].lastIndexOf("\u0001")) { String[] splitter;
String sender = simplifyNick(dataStrings[0]); if (dataStrings.length > 2){ // Don't touch 'cuz it's important
String message = dataStrings[2].substring(dataStrings[2].indexOf(":") + 1); splitter = dataStrings[2].split(" ", 2);
systemCTCP.replyCTCP(sender, message); if (splitter.length == 2){
handleSpecial(dataStrings[1], splitter[0], splitter[1]);
} }
else { }
commander.receiver(dataStrings[0], dataStrings[2].replaceAll("^.+?:", "").trim()); continue;
writerWorker.log(dataStrings[1]+" "+dataStrings[0]+" :", dataStrings[2].replaceAll("^.+?:", "").trim()); }
} if ("PRIVMSG".equals(dataStrings[1])) {
break; if (dataStrings[2].indexOf("\u0001") < dataStrings[2].lastIndexOf("\u0001")) {
case "INNA": String sender = simplifyNick(dataStrings[0]);
String[] splitter; String message = dataStrings[2].substring(dataStrings[2].indexOf(":") + 1);
if (dataStrings.length > 2){ // Don't touch 'cuz it's important systemCTCP.replyCTCP(sender, message);
splitter = dataStrings[2].split(" ", 2); }
if (splitter.length == 2){ else {
handleSpecial(dataStrings[0], splitter[0], splitter[1]); commander.receiver(dataStrings[0], dataStrings[2].replaceAll("^.+?:", "").trim());
} writerWorker.log(dataStrings[1] + " " + dataStrings[0] + " :", dataStrings[2].replaceAll("^.+?:", "").trim());
} }
break; }
default: else {
handleNumeric(dataStrings[0], dataStrings[1], dataStrings[2]); handleNumeric(dataStrings[0], dataStrings[1], dataStrings[2]);
} }
} }
} }
@ -107,8 +108,7 @@ 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 = event+" "+nick+" "+channelName+" "+message; String ircFormatterMessage = nick+" "+event+" "+channelName+" "+message;
ircChannel.getChannelQueue().add(ircFormatterMessage); ircChannel.getChannelQueue().add(ircFormatterMessage);
} }
//todo: handle nickserv messages somehow //todo: handle nickserv messages somehow