Preliminary message handling overhauls (also fixes DMs being catastrophically broken).

This commit is contained in:
flash 2024-05-07 21:08:53 +00:00
parent 4741190913
commit c379c4bd0e
10 changed files with 288 additions and 273 deletions
src/mami.js

View file

@ -1,4 +1,3 @@
#include messages.js
#include utility.js
#include ui/markup.js
@ -109,18 +108,17 @@ Umi.Parsing = (function() {
}
const extractMotiv = function(elem) {
const msgId = parseInt(elem.parentNode.parentNode.parentNode.parentNode.id.substring(8));
let topText = 'Top Text',
bottomText = 'Bottom Text';
let topText = 'Top Text';
let bottomText = 'Bottom Text';
const msg = Umi.Messages.Get(msgId);
if(msg) {
const msgText = msg.getText().replace(/\[(.*?)\](.*?)\[\/(.*?)\]/g, '').trim();
const root = elem.closest('.message');
if(root instanceof Element && 'body' in root.dataset) {
const msgText = root.dataset.body.replace(/\[(.*?)\](.*?)\[\/(.*?)\]/g, '').trim();
if(msgText.length > 0) {
const msgTextParts = msgText.split(' '),
topTextLength = Math.ceil(msgTextParts.length / 10),
topTextParts = msgTextParts.slice(0, topTextLength);
const msgTextParts = msgText.split(' ');
const topTextLength = Math.ceil(msgTextParts.length / 10);
const topTextParts = msgTextParts.slice(0, topTextLength);
let bottomTextParts = null;
if(msgTextParts.length === 1 || Math.random() > .7) {