This commit is contained in:
Flummi 2017-11-26 00:26:34 +01:00
parent fa6ecd2164
commit c5f2a6c5d3
3 changed files with 21 additions and 5 deletions

View File

@ -1,6 +1,17 @@
import { logger } from "../log.js";
import { getLevel } from "../admin.js";
const colors = {
red: "\x0304$1\x0F",
blue: "\x0312$1\x0F"
};
const replaceColor = (match, color, text) => {
if (colors.hasOwnProperty(color))
return colors[color].replace("\$1", text);
return text;
};
const net = require("net")
, tls = require("tls")
, EventEmitter = require("events").EventEmitter
@ -50,6 +61,8 @@ export class irc {
this.socket.on("data", msg => {
msg.split(/\r?\n|\r/).filter(tmp => tmp.length > 0).forEach(tmp => {
const cmd = this.parse(tmp);
//if(this.network === "n0xy")
// console.log(cmd);
if (this._cmd.has(cmd.command))
this._cmd.get(cmd.command)(cmd);
})
@ -91,6 +104,7 @@ export class irc {
reply: msg => this.send(`PRIVMSG ${tmp.params[0]} :${this.format(""+msg)}`),
replyAction: msg => this.send(`PRIVMSG ${tmp.params[0]} :\u0001ACTION ${this.format(""+msg)}\u0001`),
replyNotice: msg => this.send(`NOTICE ${tmp.params[0]} :${this.format(""+msg)}`),
self: this.server,
_chan: this.server.channel[tmp.params[0]],
_user: this.server.user,
_cmd: this._cmd,
@ -110,10 +124,10 @@ export class irc {
user = user.toLowerCase();
let tmpuser = {};
if(this.server.user.hasi(user) && !force) {
console.log("existiert", user);
//console.log("existiert", user);
tmpuser = this.server.user.geti(user);
if(tmpuser.cached >= ~~(Date.now() / 1000) - this._recachetime) {
console.log("already cached", user);
//console.log("already cached", user);
return;
}
}
@ -132,7 +146,7 @@ export class irc {
};
this.server.user.set(user, tmpuser);
console.log("whois", user);
//console.log("whois", user);
this.send(`WHOIS ${user}`);
}
parsePrefix(prefix) {
@ -147,6 +161,7 @@ export class irc {
return msg
.replace(/\[b\](.*?)\[\/b\]/g, "\x02$1\x0F") // bold
.replace(/\[i\](.*?)\[\/i\]/g, "\x1D$1\x0F") // italic
.replace(/\[color=(.*?)](.*?)\[\/color\]/g, replaceColor) // colors
;
}
}

View File

@ -68,6 +68,7 @@ export class tg {
.replace(">", ">")
.replace(/\[b\](.*?)\[\/b\]/g, "<b>$1</b>") // bold
.replace(/\[i\](.*?)\[\/i\]/g, "<i>$1</i>") // italic
.replace(/\[color=(.*?)](.*?)\[\/color\]/g, "$2")
;
}
}

View File

@ -25,7 +25,7 @@ module.exports = bot => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.reply(`[b](づ。◕‿‿◕。)づ" 。。・゜゜・。。・゜❤ ${args.join(" ").trim()} ❤[/b]`);
e.reply(`(づ。◕‿‿◕。)づ" [color=red]。。・゜゜・。。・゜❤[/color] [b]${args.join(" ").trim()}[/b] [color=red]❤[/color]`);
}
});
@ -38,7 +38,7 @@ module.exports = bot => {
let args = e.message.trim().split(" ");
args.shift();
args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0];
e.reply(`[b]♥♡❤♡♥ ${args.join(" ").trim()} ♥♡❤♡♥[/b]`);
e.reply(`[color=red]♡❤♡♥[/color] [b]${args.join(" ").trim()}[/b] [color=red]♥♡❤♡♥[/color]`);
}
});