128 lines
4.0 KiB
TypeScript
128 lines
4.0 KiB
TypeScript
// Metro module 11173 (f11174).
|
|
import EmojiStore from "../emojis/EmojiStore";
|
|
import MessageStore from "../../stores/MessageStore";
|
|
import { AnalyticEvents, MARKDOWN_SPOILER_WRAPPER, ME } from "../../Constants";
|
|
import { EnableTTSCommand } from "../user_settings/UserSettings";
|
|
import ChangeNicknameActionCreators from "../../actions/ChangeNicknameActionCreators";
|
|
import Module3888 from "../../_bundle/Module3888";
|
|
import { addReaction } from "../reactions/ReactionActionCreators";
|
|
import { toReactionEmoji } from "../reactions/ReactionUtils";
|
|
import MessageActionCreators from "../../actions/MessageActionCreators";
|
|
import AppAnalyticsUtils from "../app_analytics/AppAnalyticsUtils";
|
|
let c7556_9 = /\\([*?+/])/g;
|
|
let c7556_10 = {
|
|
tts: {
|
|
action: () => ({
|
|
tts: EnableTTSCommand.getSetting()
|
|
})
|
|
},
|
|
me: {
|
|
action: (a0) => ({
|
|
content: `_${a0}_`
|
|
})
|
|
},
|
|
tableflip: {
|
|
action: (a0) => ({
|
|
content: `${a0} (╯°□°)╯︵ ┻━┻`.trim()
|
|
})
|
|
},
|
|
unflip: {
|
|
action: (a0) => ({
|
|
content: `${a0} ┬─┬ノ( º _ ºノ)`.trim()
|
|
})
|
|
},
|
|
shrug: {
|
|
action: (a0) => ({
|
|
content: `${a0} ¯\\_(ツ)_/¯`.trim()
|
|
})
|
|
},
|
|
nick: {
|
|
action: (a0, { channel }) => {
|
|
if (channel.guild_id != null) {
|
|
ChangeNicknameActionCreators.changeNickname(channel.guild_id, channel.id, ME, a0);
|
|
return {
|
|
content: ""
|
|
};
|
|
}
|
|
}
|
|
},
|
|
reaction: {
|
|
match: Module3888.anyScopeRegex(/^\+:(.+?): *$/),
|
|
action: (a0, { isEdit, channel }) => {
|
|
if (!isEdit && MessageStore.hasPresent(channel.id)) {
|
|
const r17 = MessageStore.getMessages(channel.id).last();
|
|
if (r17 != null && r17.id != null) {
|
|
const byName = EmojiStore.getDisambiguatedEmojiContext(channel.guild_id).getByName(a0.trim().slice(2, -1));
|
|
if (byName != null) {
|
|
addReaction(channel.id, r17.id, toReactionEmoji(byName));
|
|
return {
|
|
content: ""
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
searchReplace: {
|
|
match: Module3888.anyScopeRegex(/^s\/([^\/\\]*(?:\\.[^\/\\]*)*)\/([^\/\\]*(?:\\.[^\/\\]*)*)(?:\/([g]*))?$/),
|
|
action: function action(a0, { isEdit, channel }) {
|
|
if (isEdit) {
|
|
return void 0;
|
|
}
|
|
const lastEditableMessage = MessageStore.getLastEditableMessage(channel.id);
|
|
if (lastEditableMessage != null && lastEditableMessage.id != null) {
|
|
const r9 = Array;
|
|
let r22 = a0.match(this.match.regex);
|
|
if (r22 == null) {
|
|
r22 = [];
|
|
}
|
|
const [, r27, r12, r28] = r9.from(r22);
|
|
let r29 = r28 == null ? void 0 : r28.split("");
|
|
if (r29 == null) {
|
|
r29 = [];
|
|
}
|
|
const r35 = r27.replace(c7556_9, (a0, a1) => a1);
|
|
const r38 = r12.replace(c7556_9, (a0, a1) => a1);
|
|
const r41 = r29.includes("g");
|
|
const content = lastEditableMessage.content;
|
|
const content2 = r41 ? content.replaceAll(r35, r38) : content.replace(r35, r38);
|
|
if (!(content2 != null && content2.trim() !== "") && lastEditableMessage.attachments.length === 0) {
|
|
MessageActionCreators.deleteMessage(channel.id, lastEditableMessage.id);
|
|
} else if (content2 !== lastEditableMessage.content) {
|
|
MessageActionCreators.editMessage(channel.id, lastEditableMessage.id, {
|
|
content: content2
|
|
});
|
|
}
|
|
return {
|
|
content: ""
|
|
};
|
|
}
|
|
return {
|
|
content: ""
|
|
};
|
|
}
|
|
},
|
|
spoiler: {
|
|
action: (a0) => ({
|
|
content: MARKDOWN_SPOILER_WRAPPER(a0).trim()
|
|
})
|
|
}
|
|
};
|
|
Object.setPrototypeOf(c7556_10, null);
|
|
export { c7556_10 as COMMANDS };
|
|
export function handleLegacyCommands(a0, a1) {
|
|
for (const key in c7556_10) {
|
|
const command = key;
|
|
const r7 = c7556_10[command];
|
|
if (r7.match != null) {
|
|
const regex = r7.match.regex;
|
|
if (regex == null ? void 0 : regex.test(a0)) {
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SLASH_COMMAND_USED, {
|
|
command
|
|
});
|
|
return r7.action(a0, a1);
|
|
}
|
|
}
|
|
}
|
|
}
|