aktueller Stand lol

This commit is contained in:
Flummi 2021-11-19 11:14:22 +00:00
parent c5ab2a3118
commit 9e4079e3f4
14 changed files with 1130 additions and 60 deletions

View File

@ -11,6 +11,7 @@
"author": "Flummi & jkhsjdhjs",
"license": "WTFPL",
"dependencies": {
"cleverbot-free": "^1.1.7",
"cuffeo": "^1.0.6-1",
"flumm-fetch-cookies": "^1.4.0",
"pg": "^8.3.0"

View File

@ -4,12 +4,13 @@ const logger = ["debug", "info", "error"];
const logfiles = logger.reduce((a, b) => ({...a, [b]: fs.createWriteStream(`./logs/${~~(Date.now() / 1000)}_${b}.log`)}), {});
export default new Proxy({}, {
get: (_, prop) => (msg, timestamp = new Date().toLocaleString()) =>
logger.includes(prop) &&
get: (_, prop) => (msg, timestamp = new Date().toLocaleString()) => {
if(!logger.includes(prop))
return;
logfiles[prop].write(JSON.stringify({
level: prop,
message: msg,
timestamp: timestamp
}) + "\n") &&
console.log(timestamp, prop, msg)
});
}) + "\n");
console.log(timestamp, prop, msg);
}});

View File

@ -1,7 +1,9 @@
import cb from "./lib/cleverbot.mjs";
//import cb from "./lib/cleverbot.mjs";
import cleverbot from 'cleverbot-free';
import oger from './lang/oger.mjs';
export default async bot => {
const cleverbot = await new cb();
//const cleverbot = await new cb();
return [{
name: "chatbot",
@ -9,12 +11,17 @@ export default async bot => {
set: "uwe",
active: true,
f: async e => {
const res = await cleverbot.ask(e.message
/*const res = await cleverbot.ask(e.message
.replace(/uw(e|i)/gi, "")
.split("?")
.join(" ")
);
e.reply(res);
e.reply(oger(res));*/
const res = await cleverbot(e.message
.replace(/uw(e|i)/gi, "")
.split("?").join(" ")
);
e.reply(oger(res));
}
}]
};

View File

@ -41,6 +41,7 @@ export default async bot => {
name: "coins",
call: /^(\.|\/)(btc|eth|xmr|xrp)/i,
set: "nxy",
active: false,
f: e => {
let currency = e.args[0] || "eur";
if(e.cmd === "xrp")

View File

@ -9,7 +9,7 @@ export default async bot => {
call: /^(\.|\/)fwshop/i,
active: true,
f: async e => {
const shopsite = await (await fetch("https://freewar.zocker.eu/")).text();
const shopsite = await (await fetch("https://freewar2.zocker.eu/")).text();
const shops = [...shopsite.matchAll(regex)].map(e => {
const [ name, tmp ] = e.groups.name.split(/\<.*\>/);
@ -26,10 +26,15 @@ export default async bot => {
};
});
e.reply([
"Die besten drei Shops:",
JSON.stringify(shops.slice(0, 3))
]);
e.reply([ "Die besten Shops:", ...shops.slice(0, 3).map(s => `${s.percent.slice(2)}%: ${s.region} - ${s.name} (X: ${s.coords.x} Y: ${s.coords.y})`) ]);
}
}, {
name: "fw_update",
call: /^(\.|\/)updateshops/i,
active: true,
f: async e => {
e.reply("Uno Momento!");
await fetch("https://north-reloaded.lima-city.de/stuff/parseshop/parse.php?force=true");
}
}];
};

View File

@ -0,0 +1,887 @@
const translations = {
"Rainer": [
"Ruiner",
"Reiner",
"Dreger",
"Kaschber",
"Legasdeniger",
"Fettsack",
"viddl Iddaliener",
"Butter",
"Mastoger",
"Suppengmogo",
"Speggi",
"Vierteltonner"
],
"Rainerle": [
"Ruinerle",
"Reinerle",
"Dregerle",
"Kaschberle",
"Legasdenigerle",
"Fettsackle",
"viddl Iddaliener",
"Butter",
"Mastogerle",
"Suppengmogole",
"Speggi"
],
"Winkler": [
"Wongl",
"Winggl",
"Lard",
"Bummsdi",
"Golem",
"Oger",
"Jutubber",
"Fettsack",
"Mastoger",
"Winklar",
"Dr.Dr.h.c.M.A Winkler",
"Speggi"
],
"Drachenlord": [
"Fettsack",
"Wiggsgrübbl",
"Speckeimer",
"Lügenlord",
"Hoch IQ Lord",
"Jutubber",
"Butter Golem",
"Mastoger",
"Mastsau",
"Oger",
"Suppengmogo",
"Gumbllord",
"Lustlord",
"Informatiklord",
"Speggi",
"Vierteltonner",
"Animewelt Lord",
"Diabetesdumbo",
"selbständiger Schichtarbeiter"
],
"Lord": [
"Lard",
"Lerd",
"Bummsdi",
"Lügenlord",
"Schwitzlord",
"Sifflord",
"Fettsack",
"begnadeter Jutubber",
"Butter Golem",
"Oger",
"Suppengmogo",
"Arbeitslord"
],
"Video": [
"fideo",
"fidio"
],
"Videos": [
"fideos",
"fidios"
],
"Drache": [
"Dreche",
"Dreger",
"Fettsack",
"viddl Iddaliener",
"Wiggsgrübbl",
"Net der Drache verdammte Aggst",
"Speckeimer",
"Suppengmogo",
"Wuchtbrummer"
],
"Bauch": [
"Plautze",
"Wampe",
"Kessel",
"Wuchtbrumme"
],
"Haus": [
"Schanze",
"Schimmelschanze",
"Ruine"
],
"Schanze": [
"Schanze",
"Schimmelschanze",
"Ruine"
],
"alter": [
"alda",
"alla "
],
"Alter": [
"Alda",
"Alla "
],
"hallo": [
"meddl loide",
"servus und wilkommen",
"gonitschiwa"
],
"Hallo": [
"Meddl loide",
"Servus und wilkommen",
"Gonitschiwa"
],
"leute": ["loide"],
"Leute": ["Loide"],
"schmeißen": ["nausgschmaßen"],
"geschmissen": ["nausgschmaßt"],
"schmeißt": ["nausschmaßen"],
"schmeiß": ["schmuaß"],
"blasen": ["blubber"],
"boxen": ["Brüggel Rausschmiß"],
"billig": ["billich"],
"Axt": ["Aggst"],
"Polizei": ["Bolizei"],
"Popcorn": ["Bobgorn"],
"popcorn": ["Bobgorn"],
"Post": ["Boscht"],
"post": ["boscht"],
"Idiot": [
"Kaggnazi",
"Wiggsgrübbl",
"Affennecher",
"Spaggn"
],
"idiot": [
"Kaggnazi",
"Wiggsgrübbl",
"Affennecher",
"Spaggn"
],
"Nazi": ["Kaggnazi"],
"nazi": ["kaggnazi"],
"Rudi": [
"Rudi",
"Rudi aus Buddeln",
"SS-Obersturmbannführer Rudolf Winkler",
"Nazi-Kriegsverbrecher Rudolf Winkler"
],
"Rita": [
"Rita",
"Riter",
"Rita aus Weiden"
],
"Ramona": [
"Ramona",
"Ramoner"
],
"reddit": ["Lachschon"],
"Musik hören": ["headbangen"],
"Musik gehört": ["geheadbangt"],
"dumm": ["brainschaden"],
"Energy": [
"Enertschie"
],
"energy": [
"enertschie"
],
"ein": ["a", "oa"],
"fit": ["fidd"],
"nicht hören": [
"Ich hör dich ned du Spack, ich hab Kopfhörer auf",
"can you not hear"
],
"Job": ["Tschobb"],
"job": ["Tschobb"],
"Hater": ["Haider"],
"hater": ["Haider"],
"Hate": ["Haid"],
"hate": ["Haid"],
"zerstören": ["zermeddln"],
"zerstört": ["zermeddld"],
"kann": ["koa"],
"Boneclinks": ["Bonklix"],
"boneclinks": ["bonklix"],
"jetzt": ["etzadla"],
"ja?": ["und weida?"],
"na und?": ["und weida?"],
"na und": ["und weida?"],
"Geld": ["Barrne"],
"Euro": ["Barrne €"],
"geld ": ["Barrne"],
"euro ": ["Barrne €"],
"Upvote": ["Barrne"],
"upvote": ["Barrne"],
"wütend": ["neutral"],
"Wütend": ["Neutral"],
"gemacht": [
"nausgrendert"
],
"raus gehaun": [
"nausgrendert"
],
"raus hauen": [
"nausrendern"
],
"gegessen": [
"neigschürt",
"neigerendert",
"neigstopft",
"neimeddld",
"in's gsicht gedrüggd",
"gnadenlos in's gsicht nei gedrüggt"
],
"fressen": [
"neinschüren",
"reinnrendern",
"neistopfen",
"neimeddln"
],
"gefressen": [
"neigschürt",
"neigerendert",
"neigstopft",
"neimeddld"
],
"essen": [
"neinschüren",
"reinnrendern",
"neistopfen",
"neimeddln",
"in's gsicht drüggen",
"gnadenlos in's gsicht drüggen"
],
"isst": [
"neirenderd",
"neischürd",
"neistopft",
"neimeddlt",
"in's gsicht drüggt",
"gnadenlos in's gsicht drüggt"
],
"Angst": ["wie se immer zuggen"],
"angst": ["wie se immer zuggen"],
"freundin": ["froindin", "lel als ob", "Gummipubbe"],
"Freundin": ["Froindin", "Lel als ob", "Gummipubbe"],
"Gummipuppe": ["Froindin"],
"gummipuppe": ["Froindin"],
"Freund": [
"Gumbl",
"Froind"
],
"freund": [
"Gumbl",
"Froind"
],
"Freunde": ["ihr Wahnsinnichen"],
"Penis": ["Speer", "Pimml", "Späher", "Pensi"],
"penis": ["Speer", "Pimml", "Späher", "pensi"],
"Katana": ["Blechklinge", "hamstori hanser schwerd"],
"katana": ["Blechklinge", "hamstori hanser schwerd"],
"sagst": ["sachste"],
"programmieren": [
"HDML proggrammiert",
"in Gimb nei speichern"
],
"sauer": ["mett"],
"Kumpel": ["Gumbl"],
"kumpel": ["gumbl"],
"Jungfrau": ["ungefickt"],
"jungfräulich": ["ungefickt"],
"Frau": ["Mulle", "Weib"],
"frau": ["mulle", "weib"],
"Frauen": ["Mullen", "Weiber"],
"bedeuten": ["imblementieren"],
"bedeutet": ["imblementiert"],
"nice": ["nais"],
"gelaufen": ["gemeddeld"],
"laufen": ["meddeln"],
"amen": ["OHNE DREGG ALDER"],
"so ist es": ["OHNE DREGG ALDER"],
"Stock": ["Sdogg"],
"mal": ["mol", "moal"],
"einma ": ["amol ", "amoal "],
"Gimp": ["Gimb"],
"Cola": ["Koler"],
"cola": ["Koler"],
"raus": ["naus"],
"Raus": ["Naus"],
"wie heißt du": ["anaddanowanaiwa Nandeska"],
"freut mich": ["hadschimi masde"],
"Zelda": [
"Zelad bride of the Wind",
"Tselda bref of se wild",
"Tselda"
],
"Bier": [
"Löschzwerg",
"Vigginger-Blud"
],
"Manieren": [
"Alda kein Erziehung genossen?",
"Eure Eltern würden sich schämen"
],
"manieren": [
"Alda kein Erziehung genossen?",
"Eure Eltern würden sich schämen"
],
"Franken": ["Meddlfranggen"],
"franken": ["meddlfranggen"],
"mittel": ["meddl"],
"Mittel": ["Meddl"],
"schlau": ["hoher Ikuh"],
"clever": ["hoher Ikuh"],
"klug": ["hoher Ikuh"],
"gut in": ["hoher Ikuh in"],
"IQ": ["Ikuh"],
"japanisch": ["jaboanisch"],
"Früher": [" mit 4 mit'm Vadda im Wald "],
"früher": [" mit 4 mit'm Vadda im Wald "],
"Life is strange": ["Life is stranger"],
"Kleinstadt": ["Klingelständer"],
"speichern": ["in Gimb neispeichern"],
"Kampfsport": ["Muay-Thai"],
"kampfsport": ["Muay-Thai"],
"hacken": [
"in Gimb neispeichern",
"in Gimb neirendern"
],
"gehackt": [
"in Gimb neispeichert",
"in Gimb neigrendert"
],
"arbeitet": [
"Schneidet, rendert, läd-hoch",
"Frisst, Wiggst, Zockt",
"Led's plaiet"
],
"Arbeit": [
"Schneiden, rendern, hochladen",
"Fressne, Wiggsne, Zockne",
"Led's plaien"
],
"arbeit": [
"schneiden, rendern, hochladen",
"fressne, Wiggsne, Zockne",
"Led's plaien"
],
"arbeiten": [
"schneiden, rendern, hochladen",
"fressne, Wiggsne, Zockne",
"Led's plain"
],
"besonders": ["höchste Wesne"],
"Gott": ["Dreche himself"],
"gott": ["Dreche himself"],
"Wahnsinnig": ["Wahnsinnicn"],
"Wahnsinnigen": ["Wahnsinnichen"],
"geschaut": ["gschaut"],
"rein": ["'nei"],
"arbeitslos": ["abbeidslos"],
"derjenige": ["derjeniche "],
"Derjenige": ["Derjeniche "],
"poetry slam": ["boedri slemm"],
"Poetry slam": ["boedri slemm"],
"Haut": ["kein Organ"],
"haut": ["kein Organ"],
"wtf": ["Wottse fack"],
"WTF": ["Wottse fack"],
"Wtf": ["Wottse fack"],
"what the fuck": ["Wottse fack"],
"What the fuck": ["Wottse fack"],
"Wow": ["Alta Falta"],
"wow": ["Alta Falta"],
"verpiss": ["fapiss"],
"hübsch": ["geiles stück du geiles"],
"Geil": ["geiles stück du geiles"],
"geil": ["geiles stück du geiles"],
"ist gut": ["bin gerückt"],
"Ist gut": ["Bin gerückt"],
"gut": [
"richtig und wichtig!",
"naise Sache"
],
"nicht": ["ned"],
"auf": ["uff"],
"ist er": ["issa"],
"wieder": ["widda"],
"Pizza": ["Piddsa"],
"pizza": ["piddsa"],
"Bombe": ["risiche Bombe"],
"Böller": ["risiche Bombe"],
"Sprengstoff": ["risiche Bombe"],
"Dynamit": ["risiche Bombe"],
"TNT": ["risiche Bombe"],
"bannen": ["den Banhammer schwingen"],
"gebannt": ["vom Banhammer erschlagen"],
"bann": ["schwing den Banhammer"],
"Frosch": ["HAHAHAHA a Frosch"],
"frosch": ["HAHAHAHA a Frosch"],
"Biker": ["Beiker"],
"biker": ["beiker"],
"awesome": ["awsem"],
"Thread": ["Treid"],
"thread": ["treid"],
"Why": ["Wai"],
"why": ["wai"],
"Bandana": ["Tabaktuch"],
"Claire": ["Klähger"],
"Cloe": ["Klöten"],
"cloe": ["klöten"],
"Collage": ["Kolasche"],
"collage": ["kolasche"],
"Computer": ["Gombjuta"],
"computer": ["gombjuta"],
"Challenge": ["Schälensch"],
"challenge": ["schälensch"],
"Details": ["Deteis"],
"details": ["deteis"],
"Flughafen": ["Flugstation"],
"flughafen": ["flugstation"],
"Footage": ["Futitch"],
"footage": ["futitch"],
"Genre": ["Genere"],
"genre": ["genere"],
"Hass": ["-"],
"hass": ["-"],
"Interview": ["Intervieu"],
"interview": ["intervieu"],
"Ironie": ["Iruni"],
"ironie": ["iruni"],
"Mettwurst": ["Meddworsd"],
"mettwurst": ["meddworsd"],
"Mittwoch": [
"Mettwoch",
"Meddlwoch"
],
"mittwoch": [
"mettwoch",
"meddlwoch"
],
"nationalsozialistisch": ["narzistisch"],
"Nationalsozialist": ["Narzist"],
"nationalsozialist": ["narzist"],
"Paparazzi": ["Parpazins"],
"paparazzi": ["parpazins"],
"PC": ["Bezeh"],
"Pc": ["Bezeh"],
"pc": ["Bezeh"],
"Pointe": ["Puernte"],
"pointe": ["puernte"],
"Realtalk": ["Real Tack"],
"realtalk": ["Real Tack"],
"recherchieren": ["reschaschieren"],
"Snapchat": ["Snapchet"],
"snapchat": ["snapchet"],
"Spaghetti": ["Spaketie"],
"spaghetti": ["spaketie"],
"Summer Breeze": ["Zummer Briis"],
"summer breeze": ["Zummer Briis"],
"summerbreeze": ["Zummer Briis"],
"Summerbreeze": ["Zummer Briis"],
"Twitter": ["Twidda"],
"twitter": ["Twidda"],
"Weiter so": ["Meddl on"],
"weiter so": ["meddl on"],
"Polizist": ["Herr Müller"],
"polizist": ["Herr Müller"],
"im ernst": ["ohne Spass alda", "ohne dregg alda"],
"im Ernst": ["ohne Spass alda", "ohne dregg alda"],
"Verhütung": ["Ferienhütte"],
"verhütung": ["Ferienhütte"],
"Verprügeln": ["Brügel rausschmeißen"],
"verprügeln": ["Brügel rausschmeißen"],
"Younow": ["Junau"],
"younow": ["Junau"],
"you now": ["Junau"],
"You Now": ["Junau"],
"You-Now": ["Junau"],
"you-now": ["Junau"],
"Youtube": ["Jutjub"],
"YouTube": ["Jutjub"],
"youtube": ["Jutjub"],
"You tube": ["Jutjub"],
"You Tube": ["Jutjub"],
"You-tube": ["Jutjub"],
"You-Tube": ["Jutjub"],
"typ": ["düb"],
"Typ": ["Düb"],
"dünn": ["dünn (Du meintest wohl fett)", "hahaha"],
"Dünn": ["Dünn (Du meintest wohl fett)", "hahaha"],
"schlank": ["schlank (Du meintest wohl fett)", "hahaha"],
"Schlank": ["Schlank (Du meintest wohl fett)", "hahaha"],
"Gehirn": ["Hörn"],
"gehirn": ["hörn"],
"Rewe": ["Zwingel"],
"rewe": ["Zwingel"],
"Ezio": [
"ETZIO, ALDA",
"ETZIO",
"ÄZZIOH",
"ÄZZIO DU BIST EIN VERDAMMTER HURENSOHN"
],
"ETZIO": [
"ETZIO, ALDA",
"ETZIO",
"ÄZZIOH",
"ÄZZIO DU BIST EIN VERDAMMTER HURENSOHN"
],
"trivial": ["trivago"],
"Trivial": ["Trivago"],
"Photoshop": ["fotoschobb"],
"dass": ["das"],
"wenn": ["wen"],
"ficken": [
"positzioniren",
"bositzioniren"
],
"wichsen": ["wiggsne"],
"masturbieren": ["wiggsne"],
"Sexschreiben": ["seggsschreibne"],
"PornHub": ["PH"],
"Pornhub": ["PH"],
"pornhub": ["PH"],
"warum": ["warummäh"],
"Warum": ["Warummäh"],
"Juden": ["jetzt der Drache"],
"juden": ["jetzt der Drache"],
"Jude": ["jetzt der Drache"],
"jude": ["jetzt der Drache"],
"TL;DR": ["könnt ihr selber lesen, bin zu faul"],
"tl;dr": ["könnt ihr selber lesen, bin zu faul"],
"Danke": ["Danke dafür iBlali"],
"weniger": ["wenicher"],
"wenig": ["a weng"],
"fake": ["feek"],
"Fakemulle": ["Feekmulle", "Beerchen"],
"Halts Maul": ["HALT *atmen* DEINE *atmen* FRESSE"],
"halts Maul": ["HALT *atmen* DEINE *atmen* FRESSE"],
"Halts maul": ["HALT *atmen* DEINE *atmen* FRESSE"],
"halts maul": ["HALT *atmen* DEINE *atmen* FRESSE"],
"tatsächlich": [
"tazächlich",
"tadzächlich",
"etzala tazächlich sogar",
"etzala tadzächlich sogar"
],
"Metal": ["Meddl"],
"Besuche": ["Pilgerreisen"],
"Besuch": ["Pilgerreise"],
"implizier": ["implementier"],
"Mund": ["Schlund"]
}
const questionMark = [
" Oda wat?",
" Hä?",
" und weida?",
"?",
"?"
];
const exclamationMark = [
" etzala!",
" tazächlich!",
" tazächlich sogar!",
" hätt ich gsachd!",
" alda!",
" des bascht scho!",
"!",
"!"
];
const dot = [" hätt ich gsachd.",
" des bascht scho.",
" alda.",
" tadsächlich sogar.",
". Etzala ",
". ",
". ",
". ",
". "
];
const twistedChars = {
"en": ["ne"],
"en.": ["ne."],
"en?": ["ne?"],
"en!": ["ne!"],
"en,": ["ne,"],
"tz": ["ds"],
"tel": ["dl"],
"tel.": ["dl."],
"tel?": ["dl?"],
"tel!": ["dl!"],
"tel,": ["dl,"],
"ph": ["f"],
"Ph": ["F"],
"pa": ["boa"],
"ck": ["gg"],
"Sp": ["Schb"],
"sp": ["schb"],
"St": ["Schd"],
"st": ["schd"],
"eug ": ["euch"],
"eug.": ["euch."],
"eug?": ["euch?"],
"eug!": ["euch!"],
"eug,": ["euch,"],
"t": ["d"],
"T": ["D"],
"v": ["f"],
"V": ["F"],
"v": ["f"],
"v.": ["f."],
"v?": ["f?"],
"v!": ["f!"],
"v,": ["f,"],
"v": ["w"],
"V": ["W"],
"xx": ["ggs"],
"XX": ["gss"],
"x": ["ggs"],
"X": ["ggs"],
"p": ["b"],
"P": ["B"],
"k": ["g"],
"K": ["G"]
};
const quotationMark = [" *ferstellt Stimme:* \"Äh, "];
export default words => {
let translated = '';
words = words.split(' ');
for(let i = 0; i < words.length; i++) {
let key = words[i];
let punctuation = RegExp(/[.,\/#!$%\^&\*;:{}=\-_`~()]/).exec(key);
key = key.replace(/[.,\/#!$%\^&\*;:{}=\-_`~()]/g, '').trim();
if(translations.hasOwnProperty(key)) {
const length = translations[key].length;
const randomWord = translations[key][Math.floor(Math.random() * length)];
punctuation = punctuation ? translatePunctuation(punctuation[0]) : '';
translated += randomWord + punctuation + ' ';
}
else {
if(punctuation)
key = key + punctuation[0];
key = translatePunctuation(key);
key = translateChars(key);
translated += translateQuotationMarks(key) + ' ';
}
}
return translated;
}
function translateChars(word) {
for(let key of Object.keys(twistedChars)) {
if(word.includes(key)) {
const replacement = twistedChars[key][0];
return word.replace(key, replacement);
}
}
return word;
}
function translatePunctuation(word) {
if(word.endsWith('!')) {
const random = Math.floor(Math.random() * exclamationMark.length);
return word.replace('!', exclamationMark[random]);
}
else if(word.endsWith('?')) {
const random = Math.floor(Math.random() * questionMark.length);
return word.replace('?', questionMark[random]);
}
else if(word.endsWith('.')) {
const random = Math.floor(Math.random() * dot.length);
return word.replace('.', dot[random]);
}
return word;
}
function translateQuotationMarks(word) {
if(word.startsWith('"'))
return word.replace('"', quotationMark[0]);
return word;
}

View File

@ -1,6 +1,5 @@
import fetch from "flumm-fetch-cookies";
import crypto from "crypto";
//import config from "../../../../cfg/config.json";
export default class cleverbot {
constructor() {
@ -18,51 +17,12 @@ export default class cleverbot {
let body = `stimulus=${escape(stimulus)}&cb_settings_scripting=no&islearning=1&icognoid=ws&icognocheck=`;
body += crypto.createHash("md5").update(body.substring(7, 33)).digest("hex");
return decodeURIComponent((await fetch("https://www.cleverbot.com/webservicemin?uc=UseOfficialCleverbotAPI", {
return decodeURIComponent((await (await fetch("https://www.cleverbot.com/webservicemin?uc=UseOfficialCleverbotAPI", {
method: "POST",
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
},
body: body
})).headers["cboutput"]);
})).text()).split("\r")[0]);
}
};
/*export default new class cleverbot {
constructor() {
this.api = "https://cleverbot.io/1.0";
this.nick = "";
this.init();
}
init() {
const options = {
method: "POST",
body: {
...config.apis.cleverbot,
...{ nick: "uwibot" }
}
};
fetch(`${this.api}/create`, options)
.then(res => res.json())
.then(res => this.nick = res.status === "success" ? res.nick: "uwibot")
.catch(err => console.log("cleverbot is offline or whatever lol"));
}
ask(msg) {
return new Promise((resolve, reject) => {
const options = {
method: "POST",
body: {
...config.apis.cleverbot,
...{
nick: this.nick,
text: msg
}
}
};
fetch(`${this.api}/ask`, options)
.then(res => res.json())
.then(res => res.status === "success"?resolve(res):reject(res.status))
.catch(err => reject("cleverbot is offline or whatever lol"));
});
}
};*/

View File

@ -0,0 +1,50 @@
import http from "http";
import https from "https";
import url from "url";
import querystring from "querystring";
const redirectStatus = new Set([ 301, 302, 303, 307, 308 ]);
const readdata = (res, mode, data = "") => new Promise((resolve, reject) => res
.setEncoding("utf8")
.on("data", chunk => data += chunk)
.on("end", () => {
switch(mode) {
case "text": resolve(data); break;
case "json": try { resolve(JSON.parse(data)); } catch(err) { reject(data); } break;
case "buffer": resolve(new Buffer.from(data)); break;
default: reject("lol no D:"); break;
}
}));
const genResolve = res => ({
body: res,
headers: res.headers,
text: () => readdata(res, "text"),
json: () => readdata(res, "json"),
buffer: () => readdata(res, "buffer")
});
const request = (a, options, resolve, reject, link = url.parse(a), body = "") => {
options = {...{ hostname: link.hostname, path: link.path, method: "GET", redirect: "follow" }, ...options};
if(options.method === "POST") {
body = typeof options.body === "object" ? querystring.stringify(options.body) : options.body;
delete options.body;
options.headers = {...options.headers, ...{
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": Buffer.byteLength(body)
}};
}
(link.protocol === "https:"?https:http).request(options, res => {
if(redirectStatus.has(res.statusCode) || options.redirect === "manual") {
switch(options.redirect) {
case "follow":
delete options.hostname;
delete options.path;
request(res.headers.location.startsWith("http") ? res.headers.location : `${link.protocol}//${link.host}${res.headers.location}`, options, resolve, reject);
break;
case "error": return reject("error lol");
}
}
else return resolve(genResolve(res));
}).on("error", err => err).end(body);
};
export default (_url, options = {}) => new Promise((resolve, reject) => request(_url, options, resolve, reject));

86
src/inc/trigger/man.mjs Normal file
View File

@ -0,0 +1,86 @@
import fetch from "./lib/fetch.mjs";
const api = {
mankier: "https://www.mankier.com/api/v2/mans/?q=",
arch: "https://man.archlinux.org/man/"
};
export default async bot => {
return [{
name: "man",
call: /^(\.|\/)man .*/i,
f: async e => {
let section = 0
, search = e.args[0]
, lang = "en";
if(e.args.length > 1)
[ search, section ] = [ e.args[1], e.args[0] ];
if(e.args.length > 2)
lang = e.args[2];
const mankier = await (await fetch(`${api.mankier}${search}${section > 0 ? `&sections=${section}` : ""}`)).json();
if(mankier.results.length === 0)
return e.reply("nothing found lol");
if(e.args[0] === "search") {
return e.reply(
mankier.results.flatMap(m => `[b]${m.name}.${m.section}[/b]: [i]${m.description}[/i]`)
);
}
try {
const man = await fetch(`${api.arch}${search}${section > 0 ? `.${section}` : ""}.${lang}`);
const title = man.body.req.path;
const mantext = (await man.text()).match(/<section class=\"Sh\">(.*?)<\/section>/gsm);
// 0 name, 1 synopsis, 2 description
const name = mantext[0].split("\n").slice(2, -1).join("\n");
const descr = mantext[2]
.replace(/<p.*/gsm, "")
.split("\n").slice(2, -1).join("\n")
.replace(/<([\/]?)(b|i)>/g, "[$1$2]")
.replace(/<.*?>/g, "");
return e.reply([
descr, `https://man.archlinux.org${title}`
]);
} catch(e) {
return e.reply("nope lol");
}
}
}]
};
//const api = "https://www.mankier.com/api/v2/mans/?q=";
//
//export default async bot => {
// return [{
// name: "man",
// call: /^(\.|\/)man .*/i,
// f: async e => {
// let section = 0
// , search = e.args[0];
//
// if(e.args.length > 1)
// [ search, section ] = [ e.args[1], e.args[0] ];
//
// const man = await (await fetch(`${api}${search}${section > 0 ? `&sections=${section}` : ""}`)).json();
// if(man.results.length === 0)
// return e.reply("nothing found lol");
//
// if(e.args[0] === "search") {
// return e.reply(
// man.results.flatMap(m => `[b]${m.name}.${m.section}[/b]: [i]${m.description}[/i]`)
// );
// }
//
// return e.reply([
// `[b]${man.results[0].name}[/b], section [b]${man.results[0].section}[/b]`,
// `[i]${man.results[0].description}[/i]`,
// `${man.results[0].url}`
// ]);
// }
// }]
//};

View File

@ -1,6 +1,12 @@
import fetch from "flumm-fetch-cookies";
const baseurl = "https://launchermeta.mojang.com/mc/game/version_manifest.json";
const jfcapi = "https://sky.matcool.site/api/upcomingEvents";
const jfctypes = [
"Cactus", "Carrot", "Cocoa Beans", "Melon",
"Mushroom", "Nether Wart", "Potato", "Pumpkin",
"Sugar Cane", "Wheat"
];
export default async bot => {
return [{
@ -18,5 +24,15 @@ export default async bot => {
`Snapshot: [b]${latest.snapshot.id}[/b] (${new Date(latest.snapshot.releaseTime).toLocaleString()})`
]);
}
}, {
name: "jfc",
call: /^(\.|\/)jfc$/i,
f: async e => {
const res = (await (await fetch(jfcapi)).json()).slice(0, 3);
e.reply([
"Upcoming Events:",
res.map(f => `time: in ${(f.timestamp - (new Date()).getTime())} seconds; crops: ${f.crops.map(g => jfctypes[g])}`).join("\n")
]);
}
}]
};

View File

@ -11,5 +11,14 @@ export default async bot => {
e.reply(stdout);
});
}
}, {
name: "uptime",
call: /^(\.|\/)uptime/i,
set: "uwe",
f: async e => {
exec(`uptime`, (err, stdout, stderr) => {
e.reply(stdout);
});
}
}];
};

40
src/inc/trigger/ttc.mjs Normal file
View File

@ -0,0 +1,40 @@
import fetch from "flumm-fetch-cookies";
export default async bot => {
return [{
name: "ttc_search",
call: /^(\.|\/)ttc/i,
active: true,
f: async e => {
let results = await (await fetch(`https://eu.tamrieltradecentre.com/pc/Trade/SearchResult?ItemNamePattern=${e.args.join(" ")}`)).text();
results = results.replace(/(\n|\r|\t)/g, '').replace(/\s{2,}/g, ' ');
let list = results.match(/<tr class=\"cursor-pointer\" data-on-click-link=\"(.*?)<\/tr>/gsm);
if(!list)
return e.reply("nope");
try {
const items = list.map(l => {
const n = l.match(/<div class=\"item-quality-epic\">(?<name>.*?)<\/div>/gsm)?.[0].replace(/<.*>(.*?)<\/div>/, "$1").trim();
const m = l.match(/<div>(.*?)<\/div>/gsm);
const level = +m[0].replace(/.*> (\d+?)<.*/, "$1").trim();
const region = m[1].replace(/(<div>|<\/div>)/g, '').replace(/&#(\d+);/gi, (_, num) => String.fromCharCode(+num, 10)).trim().replace(/\n/g, '');
const guild = m[2].replace(/(<div>|<\/div>)/g, '').trim();
const price = l.match(/gold\.png\" \/>(.*?)<div/gsm)[0].replace(/.*>(.*?)<.*/, "$1").trim();
return {
name: n ?? e.args.join(" "),
level: level,
region: region,
guild: guild,
price: price
};
});
return e.reply(
items.slice(0, 3).map(f => `${f.name}: ${f.region} ${f.guild} - ${f.price} gold`)
);
} catch(err) {
return e.reply(err);
}
}
}];
};

View File

@ -25,4 +25,4 @@ export default async bot => {
return e.reply(meme.url);
}
}]
};
};

7
start.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
while true
do
npm start
sleep 1
done