Spurdomod

This commit is contained in:
Flummi 2017-11-28 16:39:43 +01:00
parent 770cf8d233
commit a35606a8c5
2 changed files with 41 additions and 6 deletions

View File

@ -1,5 +1,6 @@
import { logger } from "../log.js";
import { getLevel } from "../admin.js";
import { spurdo } from "../spurdo.js";
const tgapi = require("node-telegram-bot-api")
, EventEmitter = require("events").EventEmitter
@ -15,7 +16,11 @@ export class tg {
this.server = {
channel: new Map(),
user: new Map()
user: new Map(),
me: {
nickname: "Uwe"
},
spurdo: false
};
this.client.on("message", msg => {
@ -53,11 +58,7 @@ export class tg {
account: tmp.from.id.toString()
})
},
self: {
me: {
nickname: "Uwe"
}
},
self: this.server,
message: tmp.text,
time: tmp.date,
raw: tmp,
@ -68,6 +69,8 @@ export class tg {
};
}
format(msg) {
if(this.server.spurdo)
msg = spurdo(msg);
return msg.toString()
.replace("<", "&lt;")
.replace(">", "&gt;")

32
src/inc/spurdo.js Normal file
View File

@ -0,0 +1,32 @@
const ebinFaces = [
':D', ':DD', ':DDD', ':-D',
'XD', 'XXD', 'XDD', 'XXDD'
];
const replacements = [
['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']
];
export function spurdo(text) {
text = text.toLowerCase();
replacements.forEach(filter => {
let replaceFrom = new RegExp(filter[0], 'gm')
, replaceTo = filter[1];
text = text.replace(replaceFrom, replaceTo);
});
while (text.match(/\.|,(?=\s|$)/m))
text = text.replace(/\.|,(?=\s|$)/m, ' ' + ebinFaces[~~(Math.random() * ebinFaces.length)]);
return text;
}