Implemented leetSpeak
This commit is contained in:
parent
05192a00cd
commit
e76bf15135
@ -11,6 +11,13 @@ class ChatInputComponent extends NjetComponent {
|
||||
hiddenCompletions = {
|
||||
"/starsRender": () => {
|
||||
app.rpc.starsRender(this.channelUid, this.value.replace("/starsRender ", ""))
|
||||
},
|
||||
"/leet": () => {
|
||||
this.value = this.textToLeet(this.value);
|
||||
this._leetSpeak = !this._leetSpeak;
|
||||
},
|
||||
"/l33t": () => {
|
||||
this._leetSpeakAdvanced = !this._leetSpeakAdvanced;
|
||||
}
|
||||
};
|
||||
|
||||
@ -21,7 +28,8 @@ class ChatInputComponent extends NjetComponent {
|
||||
expiryTimer = null;
|
||||
queuedMessage = null;
|
||||
lastMessagePromise = null;
|
||||
|
||||
_leetSpeak = false;
|
||||
_leetSpeakAdvanced = false;
|
||||
constructor() {
|
||||
super();
|
||||
this.lastUpdateEvent = new Date();
|
||||
@ -139,6 +147,100 @@ class ChatInputComponent extends NjetComponent {
|
||||
|
||||
return updatedText;
|
||||
}
|
||||
textToLeet(text) {
|
||||
// L33t speak character mapping
|
||||
const leetMap = {
|
||||
'a': '4',
|
||||
'A': '4',
|
||||
'e': '3',
|
||||
'E': '3',
|
||||
'i': '1',
|
||||
'I': '1',
|
||||
'o': '0',
|
||||
'O': '0',
|
||||
's': '5',
|
||||
'S': '5',
|
||||
't': '7',
|
||||
'T': '7',
|
||||
'l': '1',
|
||||
'L': '1',
|
||||
'g': '9',
|
||||
'G': '9',
|
||||
'b': '6',
|
||||
'B': '6',
|
||||
'z': '2',
|
||||
'Z': '2'
|
||||
};
|
||||
|
||||
// Convert text to l33t speak
|
||||
return text.split('').map(char => {
|
||||
return leetMap[char] || char;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
|
||||
// Advanced version with random character selection
|
||||
textToLeetAdvanced(text) {
|
||||
const leetMap = {
|
||||
'a': ['4', '@', '/\\'],
|
||||
'A': ['4', '@', '/\\'],
|
||||
'e': ['3', '€'],
|
||||
'E': ['3', '€'],
|
||||
'i': ['1', '!', '|'],
|
||||
'I': ['1', '!', '|'],
|
||||
'o': ['0', '()'],
|
||||
'O': ['0', '()'],
|
||||
's': ['5', '$'],
|
||||
'S': ['5', '$'],
|
||||
't': ['7', '+'],
|
||||
'T': ['7', '+'],
|
||||
'l': ['1', '|'],
|
||||
'L': ['1', '|'],
|
||||
'g': ['9', '6'],
|
||||
'G': ['9', '6'],
|
||||
'b': ['6', '|3'],
|
||||
'B': ['6', '|3'],
|
||||
'z': ['2'],
|
||||
'Z': ['2'],
|
||||
'h': ['#', '|-|'],
|
||||
'H': ['#', '|-|'],
|
||||
'n': ['|\\|'],
|
||||
'N': ['|\\|'],
|
||||
'm': ['|\\/|'],
|
||||
'M': ['|\\/|'],
|
||||
'w': ['\\/\\/'],
|
||||
'W': ['\\/\\/'],
|
||||
'v': ['\\/', 'V'],
|
||||
'V': ['\\/', 'V'],
|
||||
'u': ['|_|'],
|
||||
'U': ['|_|'],
|
||||
'r': ['|2'],
|
||||
'R': ['|2'],
|
||||
'f': ['|='],
|
||||
'F': ['|='],
|
||||
'd': ['|)'],
|
||||
'D': ['|)'],
|
||||
'c': ['(', '['],
|
||||
'C': ['(', '['],
|
||||
'k': ['|<'],
|
||||
'K': ['|<'],
|
||||
'p': ['|>'],
|
||||
'P': ['|>'],
|
||||
'x': ['><'],
|
||||
'X': ['><'],
|
||||
'y': ['`/'],
|
||||
'Y': ['`/']
|
||||
};
|
||||
|
||||
return text.split('').map(char => {
|
||||
const options = leetMap[char];
|
||||
if (options) {
|
||||
return options[Math.floor(Math.random() * options.length)];
|
||||
}
|
||||
return char;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
|
||||
async connectedCallback() {
|
||||
this.user = null;
|
||||
@ -287,7 +389,14 @@ class ChatInputComponent extends NjetComponent {
|
||||
}
|
||||
|
||||
async finalizeMessage(messageUid) {
|
||||
await app.rpc.sendMessage(this.channelUid, this.replaceMentionsWithAuthors(this.value), true);
|
||||
let value = this.value;
|
||||
value = this.replaceMentionsWithAuthors(value)
|
||||
if(this._leetSpeak){
|
||||
value = this.textToLeet(value);
|
||||
}else if(this._leetSpeakAdvanced){
|
||||
value = this.textToLeetAdvanced(value);
|
||||
}
|
||||
await app.rpc.sendMessage(this.channelUid, value , true);
|
||||
this.value = "";
|
||||
this.messageUid = null;
|
||||
this.queuedMessage = null;
|
||||
|
Loading…
Reference in New Issue
Block a user