CTCV2/app/src/main/java/cutthecord/commands/commands/CmdCtc.java

175 lines
4.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package cutthecord.commands.commands;
import androidx.annotation.Nullable;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreUserSettings;
import cutthecord.commands.CommandHandler;
import lanchon.dexpatcher.annotation.DexAdd;
@DexAdd
public class CmdCtc extends CommandHandler.PrivateCommand {
@DexAdd
@Override
public String handleCommand(String msg) {
// Command only has subcommands
return "CTC: No known command supplied. (available: "+ getSubCommandNames() +". Everything except specified token needs to be lowercase)";
}
@DexAdd
@Nullable
@Override
public String getPopupInfo() {
return null;
}
@DexAdd
public static class CmdCtcChannelLeak extends CommandHandler.PrivateCommand {
@DexAdd
@Override
public String handleCommand(String msg) {
StoreStream.getUserSettings().setLeakChannels(msg.startsWith("false"));
return "CTC: Successfully set channelleak state.";
}
@DexAdd
@Override
public String getPopupInfo() {
return "Shows all channels, even those you dont have permissions to view";
}
}
@DexAdd
public static class CmdCtcShowTyping extends CommandHandler.PrivateCommand {
@DexAdd
@Override
public String handleCommand(String msg) {
StoreStream.getUserSettings().setShowTyping(msg.startsWith("true"));
return "CTC: Successfully set showtyping state.";
}
@DexAdd
@Override
public String getPopupInfo() {
return "Change typing event so that its visible/not when you type";
}
}
@DexAdd
public static class CmdCtcToken extends CommandHandler.PrivateCommand {
@DexAdd
@Override
public String handleCommand(String msg) {
if (msg.isEmpty()) {
// Print token
return StoreStream.getUserSettings().getStoredToken();
}
// Set token
StoreStream.getUserSettings().setStoredToken(msg);
return "CTC: Successfully changed token. Please restart application.";
}
@DexAdd
@Override
public String getPopupInfo() {
return "Gives or sets token";
}
}
@DexAdd
public static class CmdCtcAccount extends CommandHandler.PrivateCommand {
@DexAdd
@Override
public String handleCommand(String msg) {
String trim = msg.trim();
StoreUserSettings userSettings = StoreStream.getUserSettings();
String accountToken = userSettings.getAccountToken(trim);
if (accountToken.startsWith("none")) {
return "CTC: No such account found.";
}
userSettings.setStoredToken(accountToken);
return "CTC: Successfully changed accounts. Please restart application.";
}
@DexAdd
@Override
public String getPopupInfo() {
return "Switches to the account specified";
}
}
@DexAdd
public static class CmdCtcAddAccount extends CommandHandler.PrivateCommand {
@DexAdd
@Override
public String handleCommand(String msg) {
String substring3 = msg.substring(msg.indexOf(" "));
String trim2 = msg.replace(substring3, "").trim();
String trim3 = substring3.trim();
StoreUserSettings userSettings2 = StoreStream.getUserSettings();
if (trim2.startsWith("current")) {
trim2 = userSettings2.getStoredToken();
}
userSettings2.setAccountToken(trim2, trim3);
return "CTC: Added account.";
}
@DexAdd
@Override
public String getPopupInfo() {
return "Adds an account to the account switcher";
}
}
@DexAdd
public static class CmdCtcNoDelete extends CommandHandler.PrivateCommand {
@DexAdd
@Override
public String handleCommand(String msg) {
StoreStream.getUserSettings().setNoDelete(msg.startsWith("true"));
return "CTC: Successfully set nodelete state.";
}
@DexAdd
@Override
public String getPopupInfo() {
return "Disables handling of message delete events";
}
}
@DexAdd
public static class CmdCtcGifAutoPlay extends CommandHandler.PrivateCommand {
@DexAdd
@Override
public String handleCommand(String msg) {
StoreStream.getUserSettings().setAutoplayGifs(msg.startsWith("true"));
return "CTC: Successfully set gifautoplay state.";
}
@DexAdd
@Override
public String getPopupInfo() {
return "Disables auto play of GIFs";
}
}
}