blah
This commit is contained in:
		| @@ -1,9 +1,8 @@ | ||||
| //import cb from "./lib/cleverbot.mjs"; | ||||
| import cleverbot from 'cleverbot-free'; | ||||
| import fetch from 'flumm-fetch-cookies'; | ||||
| import oger from './lang/oger.mjs'; | ||||
| import cfg from '../config.mjs'; | ||||
|  | ||||
| export default async bot => { | ||||
|   //const cleverbot = await new cb(); | ||||
|  | ||||
|   return [{ | ||||
|     name: "chatbot", | ||||
| @@ -11,17 +10,71 @@ export default async bot => { | ||||
|     set: "uwe", | ||||
|     active: true, | ||||
|     f: async e => { | ||||
|       /*const res = await cleverbot.ask(e.message | ||||
|         .replace(/uw(e|i)/gi, "") | ||||
|         .split("?") | ||||
|         .join(" ") | ||||
|       ); | ||||
|       e.reply(oger(res));*/ | ||||
|       const res = await cleverbot(e.message | ||||
|         .replace(/uw(e|i)/gi, "") | ||||
|         .split("?").join(" ") | ||||
|       ); | ||||
|       e.reply(oger(res).trim()); | ||||
|       if(!cfg.apis.chatbot || e.user.prefix?.toLowerCase().startsWith('uwe')) | ||||
|         return console.log('wo config?'); | ||||
|  | ||||
|       let finish = false; | ||||
|  | ||||
|       for(const api of cfg.apis.chatbot) { | ||||
|         if(finish) | ||||
|           return; | ||||
|         const opts = { | ||||
|           method: 'POST', | ||||
|           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)); | ||||
|       } | ||||
|     } | ||||
|   }] | ||||
| }; | ||||
|   | ||||
| @@ -9,7 +9,7 @@ export default async bot => { | ||||
|   return [{ | ||||
|     name: "gs", | ||||
|     call: /^(\.|\/)gs/i, | ||||
|     clients: ['tg'], | ||||
|     clients: ['tg','irc'], | ||||
|     f: async e => { | ||||
|       const servers = (await (await fetch(link)).json()).response.servers; | ||||
|  | ||||
|   | ||||
| @@ -19,6 +19,20 @@ export default async bot => { | ||||
|   } | ||||
|  | ||||
|   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", | ||||
|     call: /^(\.|\/)abschieben/i, | ||||
|     set: "uwe", | ||||
|   | ||||
| @@ -19,17 +19,23 @@ export default async bot => { | ||||
|     name: "randommeme", | ||||
|     call: /^(\.|\/)meme(.*)$/i, | ||||
|     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) | ||||
|         return e.reply("ups, dieses Meme wäre nsfw gewesen."); | ||||
|       return e.reply(meme.url); | ||||
|     } | ||||
|   }, { | ||||
|     name: "randomvieh", | ||||
|     call: /^(\.|\/)(otter|bunny)$/i, | ||||
|     call: /^(\.|\/)(otter|bunny|racc|wah)$/i, | ||||
|     f: async e => { | ||||
|       const vieh = await (await fetch(`https://api.tinyfox.dev/img?animal=${e.cmd}&json`)).json(); | ||||
|       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'))); | ||||
|     } | ||||
|   }*/] | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user