mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 05:52:38 +02:00
Image embedding.
Signed-off-by: Armored Dragon <publicmail@armoreddragon.com>
This commit is contained in:
parent
1cddc5a398
commit
ed3e629f19
1 changed files with 21 additions and 0 deletions
|
@ -462,6 +462,8 @@ Rectangle {
|
|||
// Format content
|
||||
message = formatContent(message);
|
||||
|
||||
message = embedImages(message);
|
||||
|
||||
if (type === "notification"){
|
||||
channel.append({ text: message, date: date, type: "notification" });
|
||||
last_message_user = "";
|
||||
|
@ -507,6 +509,25 @@ Rectangle {
|
|||
return mess
|
||||
}
|
||||
|
||||
function embedImages(mess){
|
||||
var image_link = /(https?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+(?:\/[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]*)(?:png|jpe?g|gif|bmp|svg|webp)/g;
|
||||
var matches = mess.match(image_link);
|
||||
var new_message = ""
|
||||
var listed = []
|
||||
var total_emeds = 0
|
||||
|
||||
new_message += mess
|
||||
|
||||
for (var i = 0; matches && matches.length > i && total_emeds < 3; i++){
|
||||
if (!listed.includes(matches[i])) {
|
||||
new_message += "<br><img src="+ matches[i] +" width='250' >"
|
||||
listed.push(matches[i]);
|
||||
total_emeds++
|
||||
}
|
||||
}
|
||||
return new_message;
|
||||
}
|
||||
|
||||
// Messages from script
|
||||
function fromScript(message) {
|
||||
let time = new Date().toLocaleTimeString(undefined, { hour12: false });
|
||||
|
|
Loading…
Reference in a new issue