/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.techcavern.wavetact.eventListeners;

import com.techcavern.wavetact.utils.IRCUtils;
import org.pircbotx.Channel;
import org.pircbotx.PircBotX;
import org.pircbotx.User;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.KickEvent;

import java.util.concurrent.TimeUnit;


/**
 * @author jztech101
 */
public class KickListener extends ListenerAdapter {
    public void onKick(KickEvent event) throws Exception {
        IRCUtils.sendRelayMessage(event.getBot(), event.getChannel(), IRCUtils.noPing(event.getUser().getNick()) + " kicked " + IRCUtils.noPing(event.getRecipient().getNick()) + " (" + event.getReason() + ")");
        Channel channel = event.getChannel();
        PircBotX network = event.getBot();
        User user = event.getUser();
        if (event.getRecipient().getNick().equals(network.getNick())) {
            int tries = 0;
            event.getBot().sendIRC().joinChannel(channel.getName());
            while (tries < 60 && !network.getUserBot().getChannels().contains(channel)) {
                event.getBot().sendIRC().joinChannel(channel.getName());
                tries++;
                TimeUnit.SECONDS.sleep(5);
            }
            if (network.getUserBot().getChannels().contains(channel) && !user.getNick().equals(network.getNick())) {
                if (IRCUtils.checkIfCanKick(channel, network, user)) {
                    IRCUtils.sendKick(network.getUserBot(), user, network, event.getChannel(), "┻━┻ ︵ ¯\\ (ツ)/¯ ︵ ┻━┻");
                } else {
                    IRCUtils.sendAction(user, network, channel, "kicks " + user.getNick() + " (┻━┻ ︵ ¯\\ (ツ)/¯ ︵ ┻━┻)", "");

                }
            }
        }
    }
}

@@ -722,20 +722,25 @@
 vent.get
-User
+Recipient
 ().getNi
@@ -752,16 +752,20 @@
  + %22
+ was
  kicked 
 %22 + 
@@ -760,16 +760,19 @@
  kicked 
+by 
 %22 + IRCU
@@ -788,33 +788,28 @@
 ng(event.get
-Recipient
+User
 ().getNick()

Update Relayed Kick Message