mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 02:44:53 -05:00
ansi colors like luftwaffe
This commit is contained in:
parent
0881a57544
commit
ad3604af04
2 changed files with 6 additions and 5 deletions
6
index.js
6
index.js
|
@ -205,7 +205,7 @@ function main() {
|
|||
|
||||
discordQueue = setInterval(function() {
|
||||
if (dcmsg.queue!='') {
|
||||
channel.send(dcmsg.queue.substring(0, 1997) + '\u200b');
|
||||
channel.send('```ansi\n' + dcmsg.queue.substring(0, 1997) + '\n```');
|
||||
dcmsg.queue = '';
|
||||
}
|
||||
}, 1000);
|
||||
|
@ -297,8 +297,8 @@ function main() {
|
|||
if (parsedMessage.extra[0].text==='Command set: ') return;
|
||||
}
|
||||
|
||||
const cleanMessage = escapeMarkdown(message.toString());
|
||||
discordMsg = /* '_ _ ' + */cleanMessage.replaceAll('@', '@\u200B').replaceAll('http', 'http\u200B');// .replace(/[\r\n]/gm, '\n')
|
||||
const cleanMessage = escapeMarkdown(message.toAnsi());
|
||||
discordMsg = /* '_ _ ' + */cleanMessage.replaceAll('@', '@\u200b\u200b\u200b\u200b\u200b').replaceAll('http', 'http\u200b\u200b\u200b\u200b\u200b');// .replace(/[\r\n]/gm, '\n')
|
||||
|
||||
consoleQueue.push(message.toAnsi());
|
||||
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
/**
|
||||
* escape markdown so on discord it will be \_ChipMC\_ instead of ChipMC in italic
|
||||
* @param {String} text
|
||||
* @param {Boolean} zwsp
|
||||
* @return {String}
|
||||
*/
|
||||
function escapeMarkdown(text) {
|
||||
function escapeMarkdown(text, zwsp) {
|
||||
try {
|
||||
var unescaped = text.replace(/\\(\*|@|_|`|~|\\)/g, '$1');
|
||||
var escaped = unescaped.replace(/(\*|@|_|`|~|\\)/g, '\\$1');
|
||||
var escaped = unescaped.replace(/(\*|@|_|`|~|\\)/g, zwsp ? '\u200b\u200b\u200b\u200b\u200b$1' : '\\$1');
|
||||
} catch (e) {
|
||||
return unescaped;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue