package com.github.NewsBotIRC;

import com.github.NewsBotIRC.cmds.Cmd;
import com.github.NewsBotIRC.cmds.CmdFactory;
import java.util.List;
import java.util.stream.Stream;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.ConnectEvent;
import org.pircbotx.hooks.types.GenericMessageEvent;

public class IRCListener extends ListenerAdapter
{
    private final IRCMediator mediator;

    public IRCListener(IRCMediator mediator)
    {
        this.mediator = mediator;
    }

    @Override
    public void onGenericMessage(GenericMessageEvent event)
    {
        if (!event.getMessage().startsWith("!")) return;

        String cmdTrigger = this.getTrigger(event.getMessage(), true);
        String cmdParams = this.removeTriggerString(event.getMessage());
        List<Cmd> cmds = CmdFactory.getInstance().getCmds();

        Stream<Cmd> actionableCmds =
                cmds.stream().filter(c -> c.get().equals(cmdTrigger));
        actionableCmds.forEach(c -> c.action(this.mediator, cmdParams));
    }

    public void onConnect(ConnectEvent event)
    {
        if (event.getBot().isNickservIdentified()) return;
        event.getBot().send().identify(
                ConfReader.getInstance().getNickserv_passwd());
    }

    private String getTrigger(String text, boolean skipCmdTrigger)
    {
        String trigger = new String();

        int i = skipCmdTrigger == true ? 1 : 0;
        for (;i < text.length(); ++i) {
            char c = text.charAt(i);

            if (!Character.isLetterOrDigit(c)) break;
            trigger += c;
        }

        return trigger;
    }

    private String removeTriggerString(String text)
    {
        return text.substring(this.getTrigger(text, true).length() + 1,
                text.length()).trim();
    }
}

@@ -1021,24 +1021,38 @@
 s));%0A    %7D%0A%0A
+    @Override%0A
     public v
@@ -1103,16 +1103,81 @@
     if (
+!ConfReader.getInstance().isIdentifyEnabled() %7C%7C%0A                
 event.ge
@@ -1215,16 +1215,17 @@
 return;%0A
+%0A
         

Fix identify bug - when disabled it tried to identify the same