/*+Copyright (c) 2015 by installgen2 <gen2@kek.club>++This program is free software: you can redistribute it and/or modify+it under the terms of the GNU General Public License as+published by the Free Software Foundation, either version 3 of the+License, or (at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty ofh+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program. If not, see <http://www.gnu.org/licenses/>+*/weechat.register("autospurdo","installgen2","1.0","GPL3","Speak in spurdo","","");weechat.hook_command("spurdosay","Say message in spurdo","","","","spurdoSay","");weechat.hook_command("togglespurdo","Toggle automatic spurdo conversion","","","","toggleSpurdo","");weechat.hook_command_run("/input return","spurdoModifier","");functionspurdoSay(data,buffer,args){varmessage=toSpurdo(args);weechat.command("","/say "+message)returnweechat.WEECHAT_RC_OK;}varspurdoEnabled=false;functionspurdoModifier(data,buffer,command){if(!spurdoEnabled||command!="/input return")returnweechat.WEECHAT_RC_OK;text=weechat.buffer_get_string(buffer,"input");if(text[0]=="/")returnweechat.WEECHAT_RC_OK;weechat.buffer_set(buffer,"input",toSpurdo(text))returnweechat.WEECHAT_RC_OK;}functiontoggleSpurdo(data,buffer,args){if(spurdoEnabled){spurdoEnabled=false;weechat.print("","Disabled automatic spurdo");}else{spurdoEnabled=true;weechat.print("","Enabled automatic spurdo");}returnweechat.WEECHAT_RC_OK;}// The following shit is from https://github.com/installgen2/libspurdo// Return a random ebin facevarebinFaces=[":D",":DD",":DDD",":-D",":-DD","XD","XXD","XDD","XXDD"];functiongetEbinFace(){returnebinFaces[Math.floor(Math.random()*ebinFaces.length)];}// define replacementsvarreplacements=[["wh","w"],["th","d"],["af","ab"],["ap","ab"],["ca","ga"],["ck","gg"],["co","go"],["ev","eb"],["ex","egz"],["et","ed"],["iv","ib"],["it","id"],["ke","ge"],["nt","nd"],["op","ob"],["ot","od"],["po","bo"],["pe","be"],["pi","bi"],["up","ub"],["va","ba"],["ck","gg"],["cr","gr"],["kn","gn"],["lt","ld"],["mm","m"],["nt","dn"],["pr","br"],["ts","dz"],["tr","dr"],["bs","bz"],["ds","dz"],["es","es"],["fs","fz"],["gs","gz"],[" is"," iz"],["ls","lz"],["ms","mz"],["ns","nz"],["rs","rz"],["ss","sz"],["ts","tz"],["us","uz"],["ws","wz"],["ys","yz"],["alk","olk"],["ing","ign"],["ic","ig"],["ng","nk"],["kek","geg"],["epic","ebin"],["some","sum"],["meme","maymay"],];functiontoSpurdo(string){// Convert to lowercase (TODO: add upercase handling)string=string.toLowerCase();// apply replacementsreplacements.forEach(function(filter){varreplaceFrom=newRegExp(filter[0],"gm"),replaceTo=filter[1];string=string.replace(replaceFrom,replaceTo);});// Replace "," and "." with ebin faceswhile(string.match(/\.|,(?=\s|$)/m)){string=string.replace(/\.|,(?=\s|$)/m," "+getEbinFace());}// append an ebin face if not foundvarebinFaceFound=false;ebinFaces.forEach(function(face){if(string.indexOf(face)!=-1){ebinFaceFound=true;}});if(!ebinFaceFound){string+=" "+getEbinFace();}// return spurdo'd textreturnstring;}