stuff
This commit is contained in:
parent
bce4191a24
commit
a2e7aa0983
|
@ -2,6 +2,7 @@
|
|||
|
||||
var CustomQuoter = (_ => {
|
||||
var _this;
|
||||
var settings = {}, formats = {};
|
||||
|
||||
const PreviewMessage = class PreviewMessage extends BdApi.React.Component {
|
||||
render() {
|
||||
|
@ -214,13 +215,11 @@ var CustomQuoter = (_ => {
|
|||
}
|
||||
|
||||
parseQuote (message, channel) {
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let customQuote = BDFDB.DataUtils.get(this, "formats", "customQuote");
|
||||
let languageId = BDFDB.LanguageUtils.getLanguage().id;
|
||||
|
||||
let timestamp = new Date(message.editedTimestamp || message.timestamp);
|
||||
let hour = timestamp.getHours(), minute = timestamp.getMinutes(), second = timestamp.getSeconds(), msecond = timestamp.getMilliseconds(), day = timestamp.getDate(), month = timestamp.getMonth()+1, timemode = "";
|
||||
if (customQuote.indexOf("$timemode") > -1) {
|
||||
if (formats.customQuote.indexOf("$timemode") > -1) {
|
||||
timemode = hour >= 12 ? "PM" : "AM";
|
||||
hour = hour % 12;
|
||||
hour = hour ? hour : 12;
|
||||
|
@ -236,7 +235,7 @@ var CustomQuoter = (_ => {
|
|||
|
||||
let member = BDFDB.LibraryModules.MemberStore.getMember(guild && guild.id, message.author.id);
|
||||
|
||||
return BDFDB.StringUtils.insertNRST(customQuote)
|
||||
return BDFDB.StringUtils.insertNRST(formats.customQuote)
|
||||
.replace("$mention", settings.ignoreMentionInDM && channel.isDM() ? "" : `<@!${message.author.id}>`)
|
||||
.replace("$link", `https://discordapp.com/channels/${guild.id}/${channel.id}/${message.id}`)
|
||||
.replace("$authorName", member && member.nick || message.author.username || "")
|
||||
|
@ -264,14 +263,17 @@ var CustomQuoter = (_ => {
|
|||
}
|
||||
|
||||
addLeadingZeros (timestring) {
|
||||
let chararray = timestring.split("");
|
||||
let charArray = timestring.split("");
|
||||
let numreg = /[0-9]/;
|
||||
for (let i = 0; i < chararray.length; i++) if (!numreg.test(chararray[i-1]) && numreg.test(chararray[i]) && !numreg.test(chararray[i+1])) chararray[i] = "0" + chararray[i];
|
||||
for (let i = 0; i < charArray.length; i++) if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
||||
|
||||
return chararray.join("");
|
||||
return charArray.join("");
|
||||
}
|
||||
|
||||
forceUpdateAll() {
|
||||
settings = BDFDB.DataUtils.get(this, "settings");
|
||||
formats = BDFDB.DataUtils.get(this, "formats");
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
BDFDB.MessageUtils.rerenderAll();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
var DisplayLargeMessages = (_ => {
|
||||
var encodedMessages, requestedMessages, oldMessages, updateTimeout;
|
||||
var settings = {}, amounts = {};
|
||||
|
||||
return class DisplayLargeMessages {
|
||||
getName () {return "DisplayLargeMessages";}
|
||||
|
@ -178,22 +179,20 @@ var DisplayLargeMessages = (_ => {
|
|||
}
|
||||
|
||||
processMessages (e) {
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
e.instance.props.channelStream = [].concat(e.instance.props.channelStream);
|
||||
for (let i in e.instance.props.channelStream) {
|
||||
let message = e.instance.props.channelStream[i].content;
|
||||
if (message) {
|
||||
if (BDFDB.ArrayUtils.is(message.attachments)) this.checkMessage(e.instance, e.instance.props.channelStream[i], message, settings, amounts);
|
||||
if (BDFDB.ArrayUtils.is(message.attachments)) this.checkMessage(e.instance, e.instance.props.channelStream[i], message);
|
||||
else if (BDFDB.ArrayUtils.is(message)) for (let j in message) {
|
||||
let childMessage = message[j].content;
|
||||
if (childMessage && BDFDB.ArrayUtils.is(childMessage.attachments)) this.checkMessage(e.instance, message[j], childMessage, settings, amounts);
|
||||
if (childMessage && BDFDB.ArrayUtils.is(childMessage.attachments)) this.checkMessage(e.instance, message[j], childMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkMessage (instance, stream, message, settings, amounts) {
|
||||
checkMessage (instance, stream, message) {
|
||||
let encodedContent = encodedMessages[message.id];
|
||||
if (encodedContent != null) {
|
||||
if (message.content.indexOf(encodedContent.attachment) == -1) {
|
||||
|
@ -222,39 +221,38 @@ var DisplayLargeMessages = (_ => {
|
|||
}
|
||||
|
||||
processAttachment (e) {
|
||||
if (e.instance.props.filename == "message.txt") {
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
if (settings.onDemand || amounts.maxFileSize && (amounts.maxFileSize < e.instance.props.size/1024)) e.returnvalue.props.children.splice(2, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: this.labels.button_injectattchment_text,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {
|
||||
rel: "noreferrer noopener",
|
||||
target: "_blank",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
className: BDFDB.disCN._displaylargemessagesinjectbutton,
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT,
|
||||
width: 20,
|
||||
height: 20
|
||||
}),
|
||||
onClick: event => {
|
||||
BDFDB.ListenerUtils.stopEvent(event);
|
||||
let target = event.target;
|
||||
let message = BDFDB.ReactUtils.findValue(target, "message", {up: true});
|
||||
if (message) BDFDB.LibraryRequires.request(e.instance.props.url, (error, response, body) => {
|
||||
oldMessages[message.id] = new BDFDB.DiscordObjects.Message(message);
|
||||
encodedMessages[message.id] = {
|
||||
content: message.content || "",
|
||||
attachment: body || ""
|
||||
};
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this, "Messages");
|
||||
});
|
||||
}
|
||||
})
|
||||
}));
|
||||
}
|
||||
if (e.instance.props.filename == "message.txt" && settings.onDemand || amounts.maxFileSize && (amounts.maxFileSize < e.instance.props.size/1024)) e.returnvalue.props.children.splice(2, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: this.labels.button_injectattchment_text,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {
|
||||
rel: "noreferrer noopener",
|
||||
target: "_blank",
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
||||
className: BDFDB.disCN._displaylargemessagesinjectbutton,
|
||||
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT,
|
||||
width: 20,
|
||||
height: 20
|
||||
}),
|
||||
onClick: event => {
|
||||
BDFDB.ListenerUtils.stopEvent(event);
|
||||
let target = event.target;
|
||||
let message = BDFDB.ReactUtils.findValue(target, "message", {up: true});
|
||||
if (message) BDFDB.LibraryRequires.request(e.instance.props.url, (error, response, body) => {
|
||||
oldMessages[message.id] = new BDFDB.DiscordObjects.Message(message);
|
||||
encodedMessages[message.id] = {
|
||||
content: message.content || "",
|
||||
attachment: body || ""
|
||||
};
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this, "Messages");
|
||||
});
|
||||
}
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
forceUpdateAll () {
|
||||
settings = BDFDB.DataUtils.get(this, "settings");
|
||||
amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
|
||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||
BDFDB.MessageUtils.rerenderAll();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue