public static void saveIgnored(Arisu ar) { try { File file = new File("ignored.txt"); FileWriter d = new FileWriter(file); StringBuilder f = new StringBuilder(); for (int i = 0; i < ar.ignored.size(); i++) { f.append(ar.ignored.get(i).toString()); f.append("\n"); } d.flush(); d.write(f.toString()); d.close(); Files.loadIgnored(ar); } catch (Exception ex) { System.out.println("save-ignored error: " + ex); } }
public static void loadChannels(Arisu ar) throws Exception { File file = new File("channels.txt"); if (!file.exists()) { file.createNewFile(); } BufferedReader read = new BufferedReader(new FileReader(file)); String line; while ((line = read.readLine()) != null) { if (!ar.channels.contains(line)) { if (!line.startsWith("!") && !line.isEmpty()) { ar.channels.add(line); ar.joinChannel(line); Files.loadlog(ar, line); } } } System.out.println("loaded channels.txt"); System.out.println("channels: " + ar.channels.toString()); }
public void onMessage(String channel, String sender, String login, String hostname, String msg) { String[] args = msg.split(" "); String cleancmd = args[0]; String message = msg.replace(commandprefix, "").toLowerCase(); if (cleancmd.startsWith("?help")) { StringBuilder cmdlist = new StringBuilder(); for (Commands command : cmds) { cmdlist.append("?"); cmdlist.append(command.getCommandName()); cmdlist.append(", "); } this.sendMessage(channel, "Commands: " + cmdlist.toString()); } else if (cleancmd.startsWith(commandprefix)) { for (Commands command : cmds) { if (cleancmd.startsWith(commandprefix + command.getCommandName())) { Files.savelog(this, channel, sender, msg); command.handleMessage( this, channel, sender, message.replace(command.getCommandName(), "").trim(), args); } } } }
public static void savelog(Arisu ar, String channel, String user, String msg) { try { Files.loadlog(ar, channel); File dir = new File("logs"); if (!dir.exists()) { dir.mkdir(); } File file = new File(dir + "/" + channel + ".log"); FileWriter d = new FileWriter(file); StringBuilder f = new StringBuilder(); for (int i = 0; i < ar.log.size(); i++) { f.append(ar.log.get(i).toString()); f.append("\n"); } f.append(msg); f.append("\n"); d.flush(); d.write(f.toString()); d.close(); } catch (Exception ex) { System.out.println("savelog error: " + ex); } }