This commit is contained in:
Flummi 2019-11-19 04:45:54 +01:00
parent 2988582905
commit e1b72f0f47
6 changed files with 63 additions and 4 deletions

View File

@ -15,7 +15,7 @@ const timeout = 1000;
this.level = args.level || 0; this.level = args.level || 0;
this.active = args.hasOwnProperty("active") ? args.active : true; this.active = args.hasOwnProperty("active") ? args.active : true;
this.set = args.set || "all"; // uwe, nxy, f0ck, all this.set = args.set || "all"; // uwe, nxy, f0ck, all
this.clients = args.clients || [ "irc", "tg" ]; this.clients = args.clients || [ "irc", "tg", "slack" ];
this.f = args.f; this.f = args.f;
}, },
bot: await new cuffeo(config.clients) bot: await new cuffeo(config.clients)

View File

@ -32,7 +32,7 @@ export default async bot => {
console.log(`triggered > ${t[0]}`); console.log(`triggered > ${t[0]}`);
} }
catch(error) { catch(error) {
e.reply("An error occured."); e.reply(`${t[0]}: An error occured.`);
logger.error(`${e.network} -> ${e.channel} -> ${e.user.nick}: ${error.toString ? error : JSON.stringify(error)}`); logger.error(`${e.network} -> ${e.channel} -> ${e.user.nick}: ${error.toString ? error : JSON.stringify(error)}`);
} }
}); });

View File

@ -5,6 +5,7 @@ export default async bot => {
name: "chatbot", name: "chatbot",
call: /^(?![!./[])(.*uw(e|i).*)/i, call: /^(?![!./[])(.*uw(e|i).*)/i,
set: "uwe", set: "uwe",
active: false,
f: async e => { f: async e => {
const res = await cleverbot.ask(e.message const res = await cleverbot.ask(e.message
.replace(/uw(e|i)/gi, "") .replace(/uw(e|i)/gi, "")

View File

@ -19,7 +19,7 @@ export default new class cleverbot {
fetch(`${this.api}/create`, options) fetch(`${this.api}/create`, options)
.then(res => res.json()) .then(res => res.json())
.then(res => this.nick = res.status === "success" ? res.nick: "uwibot") .then(res => this.nick = res.status === "success" ? res.nick: "uwibot")
.catch(err => console.log(err)); .catch(err => console.log("cleverbot is offline or whatever lol"));
} }
ask(msg) { ask(msg) {
@ -37,7 +37,7 @@ export default new class cleverbot {
fetch(`${this.api}/ask`, options) fetch(`${this.api}/ask`, options)
.then(res => res.json()) .then(res => res.json())
.then(res => res.status === "success"?resolve(res):reject(res.status)) .then(res => res.status === "success"?resolve(res):reject(res.status))
.catch(err => reject(err)); .catch(err => reject("cleverbot is offline or whatever lol"));
}); });
} }
}; };

View File

@ -0,0 +1,22 @@
import fetch from "flumm-fetch-cookies";
const baseurl = "https://launchermeta.mojang.com/mc/game/version_manifest.json";
export default async bot => {
return [{
name: "mcversion",
call: /^(\.|\/)mcv$/i,
f: async e => {
const res = await (await fetch(baseurl)).json();
const latest = {
release: res.versions.filter(a => a.id === res.latest.release)[0],
snapshot: res.versions.filter(a => a.id === res.latest.snapshot)[0]
};
e.reply([
`Release: [b]${latest.release.id}[/b] (${new Date(latest.release.releaseTime).toLocaleString()})`,
`Snapshot: [b]${latest.snapshot.id}[/b] (${new Date(latest.snapshot.releaseTime).toLocaleString()})`
]);
}
}]
};

36
src/inc/trigger/ts.mjs Normal file
View File

@ -0,0 +1,36 @@
import net from "net";
const ts = async () => new Promise(resolve => {
const sock = net.connect({
host: "f0ck.space",
port: 10011
}).setEncoding("utf-8");
sock.write("use sid=1\n");
sock.write("clientlist\n");
sock.on("data", e => {
if(!e.match(/clid/)) return;
sock.destroy();
return resolve(e
.split("|")
.filter(f => f.match(/client_type=0/))
.map(f => f
.split(" ")
.filter(g => g.match(/client_nickname/))
.map(g => g.split("=")[1])
)
.flat()
);
});
});
export default async bot => {
return [{
name: "ts",
call: /^(\.|\/)ts$/i,
f: async e => {
const user = await ts();
e.reply(`aktuell sind ${user.length} Nasen mit f0ck.space verbunden: ${user.join``}`);
}
}]
};