Skip to content

Instantly share code, notes, and snippets.

@n4n0GH
Forked from fl4ke/autismo.js
Last active October 17, 2019 20:55
Show Gist options
  • Save n4n0GH/388508f0248ebc5ff4e723fb906ed8a6 to your computer and use it in GitHub Desktop.
Save n4n0GH/388508f0248ebc5ff4e723fb906ed8a6 to your computer and use it in GitHub Desktop.
Memescript for Cordless
function onMessageSend(message){
return message.replace(/%%([^%]*)%%/g, function(autismo){
autismo = autismo.split('')
for(var i=0; i<autismo.length; i++){
autismo[i] = i%2?autismo[i].toLowerCase():autismo[i].toUpperCase()
}
autismo.unshift(':npc: ')
return autismo.join('')
})
.replace(/°°([^°]*)°°/g, function(autismo){
autismo = autismo.split('')
var numWord = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
for(var i=0; i<autismo.length; i++){
if(autismo[i].match(/[A-Za-z]/g)){
autismo[i] = ":regional_indicator_"+autismo[i].toLowerCase()+":\u200b"
} else if(autismo[i].match(/[0-9]/g)){
autismo[i] = ":"+numWord[autismo[i]]+":\u200b"
} else {
autismo[i] = autismo[i]
}
}
return autismo.join('')
})
.replace(/§§([^§]*)§§/g, function(autismo){
autismo = autismo.split(' ')
for(var i=0; i<autismo.length; i++){
autismo[i] = autismo[i]+" :clap: "
}
return autismo.join('')
})
.replace(/°°|%%|§§/g, '')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment