package com.techcavern.wavetact.ircCommands.misc;

import com.techcavern.wavetact.annot.IRCCMD;
import com.techcavern.wavetact.objects.IRCCommand;
import com.techcavern.wavetact.utils.*;
import org.jooq.Record;
import org.pircbotx.Channel;
import org.pircbotx.PircBotX;
import org.pircbotx.User;

@IRCCMD
public class Tell extends IRCCommand {

    public Tell() {
        super(GeneralUtils.toArray("tell"), 1, "tell [user] [message]", "Tells a user a message the next time they speak", false);
    }

    @Override
    public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
        Record relaybotsplit = DatabaseUtils.getChannelUserProperty(IRCUtils.getNetworkNameByNetwork(network), channel.getName(), PermUtils.authUser(network, user.getNick()), "relaybotsplit");
        if (relaybotsplit == null) {
            String sender = PermUtils.authUser(network, user.getNick());
            String recipent = PermUtils.authUser(network, args[0]);
            if (recipent == null) {
                ErrorUtils.sendError(user, "Recipient must be identified");
                return;
            }
            DatabaseUtils.addTellMessage(IRCUtils.getNetworkNameByNetwork(network), sender, recipent, GeneralUtils.buildMessage(1, args.length, args));
            IRCUtils.sendMessage(user, network, channel, "Latent Message Sent", prefix);
        }
    }

}

@@ -1009,24 +1009,304 @@
 String recip
+ient;%0A            if (Registry.authedUsers.get(network).keySet().stream().filter(key -%3E Registry.authedUsers.get(network).get(key).equals(args%5B0%5D.toLowerCase())).toArray().length %3E 0) %7B%0A                recipient = args%5B0%5D.toLowerCase();%0A            %7D else %7B%0A                recipi
 ent = PermUt
@@ -1337,16 +1337,30 @@
 gs%5B0%5D);%0A
+            %7D%0A
         
@@ -1372,16 +1372,17 @@
 f (recip
+i
 ent == n
@@ -1494,32 +1494,32 @@
 ;%0A            %7D%0A
-
             Data
@@ -1599,16 +1599,17 @@
 r, recip
+i
 ent, Gen

Allow Offline Tell Messages