New emojify command
This commit is contained in:
parent
77529cbf4a
commit
63673d4ce1
6 changed files with 94 additions and 20 deletions
|
@ -18,6 +18,25 @@ import lanchon.dexpatcher.annotation.DexWrap;
|
|||
@DexEdit
|
||||
public class ModelMessage implements Model {
|
||||
|
||||
// slashcommands patch
|
||||
@DexAdd
|
||||
private boolean isCTCMessage = false;
|
||||
|
||||
@DexAdd
|
||||
public void setCTCMessage(boolean isCTCMessage) {
|
||||
this.isCTCMessage = isCTCMessage;
|
||||
}
|
||||
|
||||
@DexWrap
|
||||
public boolean canResend() {
|
||||
// Prevent resending of messages from commands that are not public.
|
||||
return canResend() && !isCTCMessage;
|
||||
}
|
||||
// end of slashcommands patch
|
||||
|
||||
|
||||
// class setup
|
||||
|
||||
@DexIgnore
|
||||
public static class Call implements Model {
|
||||
|
||||
|
@ -65,21 +84,6 @@ public class ModelMessage implements Model {
|
|||
|
||||
}
|
||||
|
||||
@DexAdd
|
||||
private boolean isCTCMessage = false;
|
||||
|
||||
@DexAdd
|
||||
public void setCTCMessage(boolean isCTCMessage) {
|
||||
this.isCTCMessage = isCTCMessage;
|
||||
}
|
||||
|
||||
@DexWrap
|
||||
public boolean canResend() {
|
||||
// Prevent resending of messages from commands that are not public.
|
||||
return canResend() && !isCTCMessage;
|
||||
}
|
||||
|
||||
|
||||
@DexIgnore
|
||||
public static ModelMessage createLocalMessage(
|
||||
String content,
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.regex.Pattern;
|
|||
import cutthecord.commands.commands.CmdBold;
|
||||
import cutthecord.commands.commands.CmdClap;
|
||||
import cutthecord.commands.commands.CmdCtc;
|
||||
import cutthecord.commands.commands.CmdEmojify;
|
||||
import cutthecord.commands.commands.CmdFlip;
|
||||
import cutthecord.commands.commands.CmdFullWidth;
|
||||
import cutthecord.commands.commands.CmdGordon;
|
||||
|
@ -122,6 +123,7 @@ public class CommandHandler {
|
|||
cmds.put("small", new CmdSmall());
|
||||
cmds.put("smaller", new CmdSmaller());
|
||||
cmds.put("st", new CmdStrikethrough());
|
||||
cmds.put("emojify", new CmdEmojify());
|
||||
|
||||
// TODO can we add an CTC user that responds for these?
|
||||
Command ctcCommand = new CmdCtc();
|
||||
|
@ -166,6 +168,7 @@ public class CommandHandler {
|
|||
|
||||
// TODO check for edge cases like /meh parsing to /me
|
||||
// TODO don't allow invalid commaands to end up in chat
|
||||
// TODO don't return aa blank message in here.
|
||||
|
||||
// Trim off "/"
|
||||
msg = msg.substring(1);
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package cutthecord.commands.commands;
|
||||
|
||||
import cutthecord.commands.CommandHandler;
|
||||
import lanchon.dexpatcher.annotation.DexAdd;
|
||||
|
||||
@DexAdd
|
||||
public class CmdEmojify extends CommandHandler.Command {
|
||||
|
||||
@DexAdd
|
||||
@Override
|
||||
public String handleCommand(String msg) {
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (char c : msg.toCharArray()) {
|
||||
s.append(emojifyChar(c));
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
@DexAdd
|
||||
@Override
|
||||
public final String getPopupInfo() {
|
||||
return "Emojify text";
|
||||
}
|
||||
|
||||
@DexAdd
|
||||
final String[] numbers = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
|
||||
|
||||
@DexAdd
|
||||
public String emojifyChar(char c) {
|
||||
if (Character.isDigit(c)) {
|
||||
int i = Integer.parseInt(Character.toString(c));
|
||||
return ":" + numbers[i] + ":";
|
||||
}
|
||||
|
||||
if (Character.isAlphabetic(c)) {
|
||||
|
||||
if (c == 'b') {
|
||||
return ":b:";
|
||||
}
|
||||
|
||||
return ":regional_indicator_" + String.valueOf(c).toLowerCase() + ":";
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case '.': return ":record_button";
|
||||
case '?': return ":grey_question:";
|
||||
case '!': return ":grey_exclamation:";
|
||||
}
|
||||
|
||||
return Character.toString(c);
|
||||
}
|
||||
|
||||
}
|
|
@ -11,14 +11,14 @@ public class CmdLenny extends CommandHandler.Command {
|
|||
@DexAdd
|
||||
@Override
|
||||
public String handleCommand(String msg) {
|
||||
return msg + " ( ͡° ͜ʖ ͡°)";
|
||||
return msg + " ( \u0361\u00B0 \u035C\u0296 \u0361\u00B0)";
|
||||
}
|
||||
|
||||
@DexAdd
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPopupInfo() {
|
||||
return null;
|
||||
return "( \u0361\u00B0 \u035C\u0296 \u0361\u00B0)";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,15 +6,26 @@ import lanchon.dexpatcher.annotation.DexAdd;
|
|||
@DexAdd
|
||||
public class CmdOwo extends CommandHandler.Command {
|
||||
|
||||
@DexAdd
|
||||
final String[] expressions = {
|
||||
">_<", ":3", "ʕʘ‿ʘʔ", ":D", "._.",
|
||||
";3", "xD", "ㅇㅅㅇ", "(人◕ω◕)",
|
||||
">_>", "ÙωÙ", "UwU", "OwO", ":P",
|
||||
"(◠‿◠✿)", "^_^", ";_;", "XDDD",
|
||||
"x3", "(• o •)", "<_<", "(・`ω´・)",
|
||||
";;w;;", ">w<", "^w^"
|
||||
};
|
||||
|
||||
@DexAdd
|
||||
@Override
|
||||
public String handleCommand(String msg) {
|
||||
return msg.replaceAll("(?:r|l)", "w")
|
||||
.replaceAll("(?:R|L)", "W")
|
||||
return msg.replaceAll("[rl]", "w")
|
||||
.replaceAll("[RL]", "W")
|
||||
.replaceAll("n([aeiou])", "ny$1")
|
||||
.replaceAll("N([aeiou])", "Ny$1")
|
||||
.replaceAll("N([AEIOU])", "NY$1")
|
||||
.replace("ove", "uv");
|
||||
.replace("ove", "uv")
|
||||
.replaceAll("!+", " "+ expressions[(int) Math.floor(Math.random()*expressions.length)]+ " ");
|
||||
}
|
||||
|
||||
@DexAdd
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.discord.widgets.chat.input.WidgetChatInputSlashAction;
|
|||
import lanchon.dexpatcher.annotation.DexEdit;
|
||||
import lanchon.dexpatcher.annotation.DexWrap;
|
||||
|
||||
// If we need to find this again in the future there should only be one class that implements WidgetChatInputSlashAction
|
||||
@DexEdit
|
||||
public final class u implements WidgetChatInputSlashAction {
|
||||
|
||||
|
|
Loading…
Reference in a new issue