/** * A static method to write a line to a BufferedOutputStream and then pass the line to the log * method of the supplied PircBot instance. * * @param bot The underlying PircBot instance. * @param out The BufferedOutputStream to write to. * @param line The line to be written. "\r\n" is appended to the end. * @param encoding The charset to use when encoing this string into a byte array. */ static void sendRawLine(PircBot bot, BufferedWriter bwriter, String line) { if (line.length() > bot.getMaxLineLength() - 2) { line = line.substring(0, bot.getMaxLineLength() - 2); } synchronized (bwriter) { try { bwriter.write(line + "\r\n"); bwriter.flush(); bot.log(">>>" + line); } catch (Exception e) { // Silent response - just lose the line. } } }
protected void onDisconnect() { // TODO Auto-generated method stub super.onDisconnect(); while (true) { try { Thread.sleep(60000); reconnect(); } catch (NickAlreadyInUseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IrcException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
protected void onJoin(String channel, String sender, String login, String hostname) { super.onJoin(channel, sender, login, hostname); if (sender.equals(this.getName()) && !quiet) this.sendMessage(channel, "Hello, I am a bot. Say \"!tweet\" and I will tweet what you say."); }