1 package rero.ircfw.data; 2 3 5 6 import rero.ircfw.interfaces.FrameworkConstants; 7 import rero.util.StringParser; 8 9 import java.util.HashMap ; 10 import java.util.regex.Pattern ; 11 12 public class MyInformationTracker extends DataEventAction implements FrameworkConstants { 13 private static String supportPattern = ":.*? 005 .*? (.*?) :.*"; 14 private static Pattern isSupport = Pattern.compile(supportPattern); 15 16 public boolean isEvent(HashMap data) { 17 String temp = (String ) data.get($EVENT$); 18 19 if ("001".equals(temp)) { 20 return true; 21 } 22 if ("305".equals(temp)) { 23 return true; 24 } 25 if ("306".equals(temp)) { 26 return true; 27 } 28 if ("005".equals(temp)) { 29 return true; 30 } 31 32 return false; 33 } 34 35 public void process(HashMap data) { 36 if ("001".equals(data.get($EVENT$))) { 37 dataList.setMyNick((String ) data.get($TARGET$)); 38 } 39 40 if ("305".equals(data.get($EVENT$))) { 41 dataList.getMyUserInformation().setBack(); 42 } 43 44 if ("306".equals(data.get($EVENT$))) { 45 dataList.getMyUserInformation().setAway(); 46 } 47 48 if ("005".equals(data.get($EVENT$))) { 49 StringParser parser = new StringParser(data.get($RAW$).toString(), isSupport); 50 if (parser.matches()) { 51 String [] temp = parser.getParsedString(0).split(" "); 52 for (int x = 0; x < temp.length; x++) { 53 String key, value; 54 55 if (temp[x].indexOf('=') > -1) { 56 key = temp[x].substring(0, temp[x].indexOf('=')); 57 value = temp[x].substring(key.length() + 1, temp[x].length()); 58 59 dataList.addSupportInfo(key, value); 60 61 if (key.equals("PREFIX")) { 62 String chars = value.substring(1, value.indexOf(')')); 63 String modes = value.substring(chars.length() + 2, value.length()); 64 65 dataList.setPrefixInfo(chars, modes); 66 } else if (key.equals("CHANMODES")) { 68 String [] groups = value.split(","); 69 if (groups.length == 4) { 71 dataList.setChanGroupMode("A", groups[0]); 72 dataList.setChanGroupMode("B", groups[1]); 73 dataList.setChanGroupMode("C", groups[2]); 74 dataList.setChanGroupMode("D", groups[3]); 75 } 76 } 77 } else { 78 dataList.addSupportInfo(temp[x], "true"); 79 } 80 } 81 } 82 } 83 84 } 85 } 86 87 | Popular Tags |