This commit is contained in:
Flummi 2023-07-09 03:16:15 +02:00
parent 17b881802e
commit 264f463a8f
4 changed files with 91 additions and 18 deletions

View File

@ -1,9 +1,8 @@
//import cb from "./lib/cleverbot.mjs"; import fetch from 'flumm-fetch-cookies';
import cleverbot from 'cleverbot-free';
import oger from './lang/oger.mjs'; import oger from './lang/oger.mjs';
import cfg from '../config.mjs';
export default async bot => { export default async bot => {
//const cleverbot = await new cb();
return [{ return [{
name: "chatbot", name: "chatbot",
@ -11,17 +10,71 @@ export default async bot => {
set: "uwe", set: "uwe",
active: true, active: true,
f: async e => { f: async e => {
/*const res = await cleverbot.ask(e.message if(!cfg.apis.chatbot || e.user.prefix?.toLowerCase().startsWith('uwe'))
.replace(/uw(e|i)/gi, "") return console.log('wo config?');
.split("?")
.join(" ") let finish = false;
);
e.reply(oger(res));*/ for(const api of cfg.apis.chatbot) {
const res = await cleverbot(e.message if(finish)
.replace(/uw(e|i)/gi, "") return;
.split("?").join(" ") const opts = {
); method: 'POST',
e.reply(oger(res).trim()); headers: api.headers,
body: JSON.stringify({
wordLimit: 160,
query: e.message.replace(/uw(e|i)/gi, "") + '. Antworte auf Deutsch in Du-Form.'
})
};
const res = await (await fetch(api.url, opts)).json();
if(res.response) {
finish = true;
return await e.reply(oger(res.response).trim());
}
}
}
}, {
name: "chatgpt",
call: /^(\.|\/)gpt/i,
set: "uwe",
active: false,
f: async e => {
if(!cfg.apis.chatgpt || e.user.prefix?.toLowerCase().startsWith('uwe'))
return console.log('wo config?');
let actcon = [];
const constr = `${e.network}::${e.channel}`;
if(conversations.has(constr))
actcon.push(...conversations.get(constr));
else
actcon.push(initial);
actcon.push({
role: 'user',
content: e.message.replace(/uw(e|i)/gi, "")
});
const opts = {
method: 'POST',
headers: cfg.apis.chatgpt.headers,
body: JSON.stringify({
model: 'gpt-3.5-turbo',
messages: actcon
})
};
const res = await (await fetch(cfg.apis.chatgpt.url, opts)).json();
if(res.choices[0]?.message) {
actcon.push(res.choices[0].message);
conversations.set(constr, actcon);
console.log(actcon);
return await e.reply(oger(res.choices[0].message.content));
}
} }
}] }]
}; };

View File

@ -9,7 +9,7 @@ export default async bot => {
return [{ return [{
name: "gs", name: "gs",
call: /^(\.|\/)gs/i, call: /^(\.|\/)gs/i,
clients: ['tg'], clients: ['tg','irc'],
f: async e => { f: async e => {
const servers = (await (await fetch(link)).json()).response.servers; const servers = (await (await fetch(link)).json()).response.servers;

View File

@ -19,6 +19,20 @@ export default async bot => {
} }
return [{ return [{
name: "opnclose",
call: /^(opn|open) ?/i,
set: "uwe",
f: e => {
e.reply('close');
}
}, {
name: "gangrape",
call: /^(\.|\/)gangrape/i,
set: "uwe",
f: e => {
e.replyAction(`gibt [b]${e.args.join(" ") || "sich selbst"}[/b] auf ${~~(Math.random() * 100)} Ebenen. Er macht wahrhaft aus ihm einen flummiIO.`);
}
}, {
name: "abschieben", name: "abschieben",
call: /^(\.|\/)abschieben/i, call: /^(\.|\/)abschieben/i,
set: "uwe", set: "uwe",

View File

@ -19,17 +19,23 @@ export default async bot => {
name: "randommeme", name: "randommeme",
call: /^(\.|\/)meme(.*)$/i, call: /^(\.|\/)meme(.*)$/i,
f: async e => { f: async e => {
const meme = await (await fetch("https://meme-api.herokuapp.com/gimme")).json(); const meme = await (await fetch("https://meme-api.com/gimme")).json();
if(meme.nsfw) if(meme.nsfw)
return e.reply("ups, dieses Meme wäre nsfw gewesen."); return e.reply("ups, dieses Meme wäre nsfw gewesen.");
return e.reply(meme.url); return e.reply(meme.url);
} }
}, { }, {
name: "randomvieh", name: "randomvieh",
call: /^(\.|\/)(otter|bunny)$/i, call: /^(\.|\/)(otter|bunny|racc|wah)$/i,
f: async e => { f: async e => {
const vieh = await (await fetch(`https://api.tinyfox.dev/img?animal=${e.cmd}&json`)).json(); const vieh = await (await fetch(`https://api.tinyfox.dev/img?animal=${e.cmd}&json`)).json();
return e.reply(`https://api.tinyfox.dev${vieh.loc}`); return e.reply(`https://api.tinyfox.dev${vieh.loc}`);
} }
}] }/*, {
name: "thispersondoesnotexist",
call: /^(\.|\/)tpdne$/i,
f: async e => {
return e.image(await (await fetch('https://thispersondoesnotexist.com/image')));
}
}*/]
}; };