forked from keinBot/cuffeo
irgendwas mit overhaul
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
export default client => {
|
||||
client._cmd.set("CAP", function (msg) { // capkram
|
||||
export default bot => {
|
||||
bot._cmd.set("CAP", msg => { // capkram
|
||||
switch (msg.params[1]) {
|
||||
case "LS": // list
|
||||
this.send(`CAP REQ :${msg.params[2]}`);
|
||||
bot.send(`CAP REQ :${msg.params[2]}`);
|
||||
break;
|
||||
case "ACK": // success
|
||||
this.send("AUTHENTICATE PLAIN");
|
||||
bot.send("AUTHENTICATE PLAIN");
|
||||
break;
|
||||
}
|
||||
}.bind(client));
|
||||
});
|
||||
|
||||
client._cmd.set("AUTHENTICATE", function (msg) { // auth
|
||||
bot._cmd.set("AUTHENTICATE", msg => { // auth
|
||||
if (msg.params[0].match(/\+/))
|
||||
this.send(`AUTHENTICATE ${new Buffer(this.username + "\u0000" + this.username + "\u0000" + this.options.password).toString("base64")}`);
|
||||
}.bind(client));
|
||||
bot.send(`AUTHENTICATE ${new Buffer(bot.username + "\u0000" + bot.username + "\u0000" + bot.options.password).toString("base64")}`);
|
||||
});
|
||||
|
||||
client._cmd.set("900", function (msg) { // cap end
|
||||
this.send("CAP END");
|
||||
}.bind(client));
|
||||
bot._cmd.set("900", msg => { // cap end
|
||||
bot.send("CAP END");
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
export default client => {
|
||||
client._cmd.set("INVITE", function (msg) { // invite
|
||||
const user = this.parsePrefix(msg.prefix);
|
||||
export default bot => {
|
||||
bot._cmd.set("INVITE", msg => { // invite
|
||||
const user = bot.parsePrefix(msg.prefix);
|
||||
const channel = msg.params[1];
|
||||
|
||||
if(!this.server.channel.includes(channel)) {
|
||||
this.join(channel);
|
||||
if(!bot.server.channel.includes(channel)) {
|
||||
bot.join(channel);
|
||||
setTimeout(() => {
|
||||
this.send(`PRIVMSG ${channel} :Hi. Wurde von ${user.nick} eingeladen.`);
|
||||
bot.send(`PRIVMSG ${channel} :Hi. Wurde von ${user.nick} eingeladen.`);
|
||||
}, 1000);
|
||||
}
|
||||
}.bind(client));
|
||||
});
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
export default client => {
|
||||
client._cmd.set("JOIN", function (msg) { // join
|
||||
this.send(`WHO ${msg.params[0]}`);
|
||||
}.bind(client));
|
||||
export default bot => {
|
||||
bot._cmd.set("JOIN", msg => { // join
|
||||
bot.send(`WHO ${msg.params[0]}`);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
export default client => {
|
||||
client._cmd.set("372", function (msg) { // motd_entry
|
||||
this.server.motd += `${msg.params[1]}\n`;
|
||||
}.bind(client));
|
||||
export default bot => {
|
||||
bot._cmd.set("372", msg => { // motd_entry
|
||||
bot.server.motd += `${msg.params[1]}\n`;
|
||||
});
|
||||
|
||||
client._cmd.set("375", function (msg) { // motd_start
|
||||
this.server.motd = `${msg.params[1]}\n`;
|
||||
}.bind(client));
|
||||
bot._cmd.set("375", msg => { // motd_start
|
||||
bot.server.motd = `${msg.params[1]}\n`;
|
||||
});
|
||||
|
||||
client._cmd.set("376", function (msg) { // motd_end
|
||||
this.server.motd += `${msg.params[1]}\n`;
|
||||
this.emit("data", ["motd", this.server.motd]);
|
||||
}.bind(client));
|
||||
bot._cmd.set("376", msg => { // motd_end
|
||||
bot.server.motd += `${msg.params[1]}\n`;
|
||||
bot.emit("data", ["motd", bot.server.motd]);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
export default client => {
|
||||
client._cmd.set("PRIVMSG", function (msg) { // privmsg
|
||||
export default bot => {
|
||||
bot._cmd.set("PRIVMSG", msg => { // privmsg
|
||||
if(msg.params[1] === "\u0001VERSION\u0001")
|
||||
return this.emit("data", ["ctcp:version", this.reply(msg)]);
|
||||
return bot.emit("data", ["ctcp:version", bot.reply(msg)]);
|
||||
else if(msg.params[1].match(/^\u0001PING .*\u0001/i))
|
||||
return this.emit("data", ["ctcp:ping", this.reply(msg)]);
|
||||
return bot.emit("data", ["ctcp:ping", bot.reply(msg)]);
|
||||
else
|
||||
this.emit("data", ["message", this.reply(msg)]);
|
||||
}.bind(client));
|
||||
bot.emit("data", ["message", bot.reply(msg)]);
|
||||
});
|
||||
|
||||
client._cmd.set("NOTICE", function (msg) { // notice
|
||||
this.emit("data", ["notice", msg.params[1]]);
|
||||
}.bind(client));
|
||||
bot._cmd.set("NOTICE", msg => { // notice
|
||||
bot.emit("data", ["notice", msg.params[1]]);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export default client => {
|
||||
client._cmd.set("NICK", function (msg) { // nickchange
|
||||
let prefix = this.parsePrefix(msg.prefix);
|
||||
if (this.server.user.hasi(prefix.nick))
|
||||
this.server.user.deli(prefix.nick);
|
||||
this.whois(msg.params[0], true); // force
|
||||
}.bind(client));
|
||||
export default bot => {
|
||||
bot._cmd.set("NICK", msg => { // nickchange
|
||||
let prefix = bot.parsePrefix(msg.prefix);
|
||||
if (bot.server.user.has(prefix.nick))
|
||||
bot.server.user.del(prefix.nick);
|
||||
bot.whois(msg.params[0], true); // force
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default client => {
|
||||
client._cmd.set("PART", function (msg) { // part
|
||||
export default bot => {
|
||||
bot._cmd.set("PART", msg => { // part
|
||||
//delete this.server.user[msg.params[0]];
|
||||
}.bind(client));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export default client => {
|
||||
client._cmd.set("PING", function (msg) { // ping
|
||||
this.send(`PONG ${msg.params.join``}`);
|
||||
}.bind(client));
|
||||
export default bot => {
|
||||
bot._cmd.set("PING", msg => { // ping
|
||||
bot.send(`PONG ${msg.params.join``}`);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default client => {
|
||||
client._cmd.set("464", function (msg) { // motd_entry
|
||||
if (this.options.password.length > 0 && !this.options.sasl)
|
||||
this.send(`PASS ${this.options.password}`);
|
||||
}.bind(client));
|
||||
export default bot => {
|
||||
bot._cmd.set("464", msg => { // motd_entry
|
||||
if (bot.options.password.length > 0 && !bot.options.sasl)
|
||||
bot.send(`PASS ${bot.options.password}`);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default client => {
|
||||
client._cmd.set("001", function (msg) { // welcome
|
||||
this.join(this.options.channels);
|
||||
this.emit("data", ["connected", msg.params[1]]);
|
||||
}.bind(client));
|
||||
export default bot => {
|
||||
bot._cmd.set("001", msg => { // welcome
|
||||
bot.join(bot.options.channels);
|
||||
bot.emit("data", ["connected", msg.params[1]]);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
const max = 400;
|
||||
let whois = [];
|
||||
let chan;
|
||||
|
||||
export default client => {
|
||||
client._cmd.set("352", function (msg) { // who_entry
|
||||
if (!this.server.channel[msg.params[1]])
|
||||
this.server.channel[msg.params[1]] = new Map();
|
||||
this.server.channel[msg.params[1]].set(msg.params[5], { // chan
|
||||
nick: msg.params[5],
|
||||
username: msg.params[2],
|
||||
hostname: msg.params[3]
|
||||
});
|
||||
export default bot => {
|
||||
bot._cmd.set("352", msg => { // who_entry
|
||||
chan = msg.params[1];
|
||||
whois.push(msg.params[5]);
|
||||
}.bind(client));
|
||||
});
|
||||
|
||||
client._cmd.set("315", function (msg) { // who_end
|
||||
this.whois(whois.reduce((a, b) => {
|
||||
a += `${b},`;
|
||||
if(a.length >= max) {
|
||||
this.whois(a.slice(0, -1));
|
||||
a = "";
|
||||
}
|
||||
return a;
|
||||
}, "").slice(0, -1));
|
||||
bot._cmd.set("315", msg => { // who_end
|
||||
bot.server.channel.set(chan, whois);
|
||||
whois = [...new Set(whois)];
|
||||
Array(Math.ceil(whois.length / 10)).fill().map(_ => whois.splice(0, 10)).forEach(l => bot.whois(l));
|
||||
whois = [];
|
||||
}.bind(client));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,37 +1,38 @@
|
||||
export default client => {
|
||||
client._cmd.set("307", function (msg) { // whois_identified (ircd-hybrid)
|
||||
export default bot => {
|
||||
bot._cmd.set("307", msg => { // whois_identified (ircd-hybrid)
|
||||
let tmpuser = {};
|
||||
if (this.server.user.hasi(msg.params[1]))
|
||||
tmpuser = this.server.user.geti(msg.params[1]);
|
||||
if (bot.server.user.has(msg.params[1]))
|
||||
tmpuser = bot.server.user.get(msg.params[1]);
|
||||
tmpuser.account = msg.params[1];
|
||||
tmpuser.registered = true;
|
||||
this.server.user.set(msg.params[1], tmpuser);
|
||||
}.bind(client));
|
||||
bot.server.user.set(msg.params[1], tmpuser);
|
||||
});
|
||||
|
||||
client._cmd.set("311", function (msg) { // whois_userdata
|
||||
bot._cmd.set("311", msg => { // whois_userdata
|
||||
let tmpuser = {};
|
||||
if (this.server.user.hasi(msg.params[1]))
|
||||
tmpuser = this.server.user.geti(msg.params[1]);
|
||||
if (bot.server.user.has(msg.params[1]))
|
||||
tmpuser = bot.server.user.get(msg.params[1]);
|
||||
tmpuser.nickname = msg.params[1];
|
||||
tmpuser.username = msg.params[2];
|
||||
tmpuser.hostname = msg.params[3];
|
||||
tmpuser.realname = msg.params[5];
|
||||
tmpuser.prefix = `${msg.params[1]}!${msg.params[2]}@${msg.params[3]}`;
|
||||
this.server.user.set(msg.params[1], tmpuser);
|
||||
}.bind(client));
|
||||
bot.server.user.set(msg.params[1], tmpuser);
|
||||
});
|
||||
|
||||
client._cmd.set("313", function (msg) { // whois_oper
|
||||
bot._cmd.set("313", msg => { // whois_oper
|
||||
let tmpuser = {};
|
||||
if (this.server.user.hasi(msg.params[1]))
|
||||
tmpuser = this.server.user.geti(msg.params[1]);
|
||||
if (bot.server.user.has(msg.params[1]))
|
||||
tmpuser = bot.server.user.get(msg.params[1]);
|
||||
tmpuser.oper = true;
|
||||
this.server.user.set(msg.params[1], tmpuser);
|
||||
}.bind(client));
|
||||
bot.server.user.set(msg.params[1], tmpuser);
|
||||
});
|
||||
|
||||
client._cmd.set("318", function (msg) { // whois_end
|
||||
bot._cmd.set("318", msg => { // whois_end
|
||||
let tmpuser = {};
|
||||
if (this.server.user.hasi(msg.params[1]))
|
||||
tmpuser = this.server.user.geti(msg.params[1]);
|
||||
bot.emit("data", ["info", `whois < ${msg.params[1]}`]);
|
||||
if (bot.server.user.has(msg.params[1]))
|
||||
tmpuser = bot.server.user.get(msg.params[1]);
|
||||
tmpuser = {
|
||||
nickname: tmpuser.nickname || false,
|
||||
username: tmpuser.username || false,
|
||||
@@ -44,18 +45,20 @@ export default client => {
|
||||
channels: tmpuser.channels || [],
|
||||
cached: ~~(Date.now() / 1000)
|
||||
};
|
||||
if(msg.params[0] === msg.params[1])
|
||||
this.server.me = tmpuser;
|
||||
this.server.user.set(msg.params[1], tmpuser);
|
||||
}.bind(client));
|
||||
bot.server.user.set(msg.params[1], tmpuser);
|
||||
if(msg.params[0] == msg.params[1]) {
|
||||
bot.server.me = tmpuser;
|
||||
bot.server.user.delete(msg.params[1]);
|
||||
}
|
||||
});
|
||||
|
||||
client._cmd.set("319", function (msg) { // whois_chanlist
|
||||
bot._cmd.set("319", msg => { // whois_chanlist
|
||||
let tmpchan = new Map()
|
||||
, tmpuser = {};
|
||||
if (this.server.user.hasi(msg.params[1])) {
|
||||
tmpuser = this.server.user.geti(msg.params[1]);
|
||||
if (tmpuser.channels)
|
||||
tmpchan = new Map(tmpuser.channels);
|
||||
if (bot.server.user.has(msg.params[1])) {
|
||||
tmpuser = bot.server.user.get(msg.params[1]);
|
||||
if (tmpuser.channels)
|
||||
tmpchan = new Map(tmpuser.channels);
|
||||
}
|
||||
let chans = msg.params[2].trim().split(" ");
|
||||
for (let chan in chans) {
|
||||
@@ -63,15 +66,15 @@ export default client => {
|
||||
tmpchan.set(`#${chan[1]}`, chan[0]);
|
||||
}
|
||||
tmpuser.channels = tmpchan;
|
||||
this.server.user.set(msg.params[1], tmpuser);
|
||||
}.bind(client));
|
||||
bot.server.user.set(msg.params[1], tmpuser);
|
||||
});
|
||||
|
||||
client._cmd.set("330", function (msg) { // whois_authed_as (snircd)
|
||||
bot._cmd.set("330", msg => { // whois_authed_as (snircd)
|
||||
let tmpuser = {};
|
||||
if (this.server.user.hasi(msg.params[1]))
|
||||
tmpuser = this.server.user.geti(msg.params[1]);
|
||||
if (bot.server.user.has(msg.params[1]))
|
||||
tmpuser = bot.server.user.get(msg.params[1]);
|
||||
tmpuser.account = msg.params[2];
|
||||
tmpuser.registered = true;
|
||||
this.server.user.set(msg.params[1], tmpuser);
|
||||
}.bind(client));
|
||||
bot.server.user.set(msg.params[1], tmpuser);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user