Exemple #1
0
 public void removeChannel(String channel, String sender) throws IOException {
   File file = new File("channels.txt");
   FileWriter d = new FileWriter(file);
   channels.remove(channel);
   StringBuilder f = new StringBuilder();
   for (int i = 0; i < channels.size(); i++) {
     if (!channels.get(i).equalsIgnoreCase(channel)) {
       f.append(channels.get(i).toString().toLowerCase());
       f.append("\n");
     }
   }
   d.flush();
   d.write(f.toString());
   d.close();
 }
Exemple #2
0
 public void appendChannel(String channel, String sender) throws IOException {
   File file = new File("channels.txt");
   FileWriter d = new FileWriter(file);
   channels.add(channel.toLowerCase());
   StringBuilder f = new StringBuilder();
   for (int i = 0; i < channels.size(); i++) {
     f.append(channels.get(i).toString());
     f.append("\n");
   }
   System.out.println("f:" + f.toString());
   d.flush();
   d.write(f.toString());
   d.close();
   this.joinChannel(channel);
   this.sendMessage(channel, "Hello ya'll. I was invited by " + sender + ".");
 }
Exemple #3
0
 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);
       }
     }
   }
 }