Arctic_Wolfy

IRC Bot Main

Nov 6th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package com.bbw2.ircBot;
  2.  
  3. import java.io.IOException;
  4.  
  5. /**
  6.  * Created on 11/3/2015.
  7.  */
  8. public class Main {
  9.     public static void main(String[] args) {
  10.         Server server;
  11.         String serverName = "irc.FurNet.org",
  12.                 nick = "ArcticBot",
  13.                 login = nick,
  14.                 pass = null;
  15.  
  16.         String[] channelNames = {"#ArcticBotTest"};
  17.  
  18.         if (args.length>0){
  19.             for (String arg : args) {
  20.                 if (arg.startsWith("server:"))
  21.                     serverName = arg.split(":")[1];
  22.                 if (arg.startsWith("nick:"))
  23.                     nick = arg.split(":")[1];
  24.                 if (arg.startsWith("pass:"))
  25.                     pass = arg.split(":")[1];
  26.                 if (arg.startsWith("channels:"))
  27.                     channelNames = arg.split(":")[1].split(",");
  28.             }
  29.         }
  30.  
  31.         Channel[] channels = new Channel[channelNames.length];
  32.         for (int i = 0; i < channelNames.length; i++)
  33.             channels[i] = new Channel(channelNames[i]);
  34.  
  35.  
  36.         server = new Server(serverName, nick, login, pass, channels);
  37.  
  38.         try {
  39.             server.init();
  40.             if (server.start())
  41.                 server.joinChannels();
  42.         } catch (IOException e) {
  43.             try {
  44.                 System.out.println("Error");
  45.                 server.getWriter().write("PRIVMEG " + channelNames[0] + ": Error\r\n");
  46.                 server.getWriter().flush();
  47.             } catch (IOException e1) {e1.printStackTrace();}
  48.             System.err.println(e.getMessage());
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment