Schmuser :_D

This commit is contained in:
Flummi 2018-06-20 03:47:32 +00:00
parent 9144dc82de
commit 6923b973ad
2 changed files with 23 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import { logger } from "../inc/log";
import { getLevel } from "../inc/admin";
import { spurdo } from "../inc/spurdo";
import { schmuser } from "../inc/schmuser";
import rp from "request-promise";
import EventEmitter from "events";
@ -21,7 +22,8 @@ export class tg extends EventEmitter {
channel: new Map(),
user: new Map(),
me: {},
spurdo: false
spurdo: false,
schmuser: false
};
this.connect().then(() => {
this.poller = setInterval(() => { this.poll(); }, this.options.pollrate);
@ -134,6 +136,8 @@ export class tg extends EventEmitter {
format(msg) {
if(this.server.spurdo)
msg = spurdo(msg);
if(this.server.schmuser)
msg = schmuser(msg);
return msg.toString()
.split("<").join("&lt;")
.split(">").join("&gt;")

18
src/inc/schmuser.mjs Normal file
View File

@ -0,0 +1,18 @@
const replacements = [
["blöd", "plöd"], ["nein", "neim"], ["ein", "1"], ["bitte", "bidde"],
["Bitte", "Bidde"], ["ich", "i"], ["Ich", "i"], ["auch", "au"],
["noch", "no"], ["Hallo", "Halo"], ["hallo", "halo"], ["bin", "bims"],
["Bin", "Bims"], ["ist", "is"], ["Ist", "Is"], ["danke", "dangge"],
["Danke", "Dangge"], ["t", "dd"], ["mm", "m"], ["n", "m"],
["mir", "mi"], ["Mir", "Mi"], ["die", "di"], ["Die", "Di"],
["Immer", "Imer"], ["immer", "imer"], ["Hab", "Han"], ["hab", "han"]
];
export function schmuser(text) {
replacements.forEach(filter => {
let replaceFrom = new RegExp(filter[0], 'gm')
, replaceTo = filter[1];
text = text.replace(replaceFrom, replaceTo);
});
return text;
}