62 lines
2.7 KiB
JavaScript
62 lines
2.7 KiB
JavaScript
const rp = require("request-promise");
|
|
|
|
module.exports = bot => {
|
|
bot._trigger.set("wttr", new bot.trigger({
|
|
call: /^\.wttr .*/i,
|
|
level: 0,
|
|
active: true,
|
|
clients: ["irc"],
|
|
f: e => {
|
|
let args = e.message.trim().substring(6);
|
|
let options = {
|
|
url: `http://wttr.in/${encodeURIComponent(args)}`,
|
|
headers: {
|
|
'User-Agent': 'curl/7.43.0',
|
|
'accept-language': 'de-DE,de'
|
|
}
|
|
};
|
|
rp(options).then(body => {
|
|
let origbody = body;
|
|
body = body
|
|
.split("\u001b[38;5;226m").join("\x0308") // yellowlight
|
|
.split("\u001b[38;5;154m").join("\x0303") // green
|
|
.split("\u001b[38;5;118m").join("\x0303") // green
|
|
.split("\u001b[38;5;190m").join("\x0309") // lime
|
|
.split("\u001b[38;5;046m").join("\x0309") // lime
|
|
.split("\u001b[38;5;048m").join("\x0309") // lime
|
|
.split("\u001b[38;5;082m").join("\x0309") // lime
|
|
.split("\u001b[38;5;047m").join("\x0309") // lime
|
|
.split("\u001b[38;5;202m").join("\x0305") // red
|
|
.split("\u001b[38;5;196m").join("\x0305") // red
|
|
.split("\u001b[38;5;220m").join("\x0304") // orange to brown
|
|
.split("\u001b[38;5;214m").join("\x0304") // orange to brown
|
|
.split("\u001b[38;5;208m").join("\x0304") // orange to brown
|
|
.split("\u001b[38;5;240;1m").join("\x0314") // darkgrey
|
|
.split("\u001b[38;5;21;1m").join("\x0302") // blue
|
|
.split("\u001b[38;5;21;25m").join("\x0302") // blue
|
|
.split("\u001b[38;5;111;25m").join("\x0311") // lightblue
|
|
.split("\u001b[38;5;111m").join("\x0311") // lightblue
|
|
.split("\u001b[38;5;251m").join("\x0315") // lightgrey
|
|
.split("\u001b[38;5;021m").join("\x0302") // arschkalt
|
|
.split("\u001b[38;5;051m").join("\x0302") // arschkalt
|
|
.split("\u001b[38;5;049m").join("\x0302") // arschkalt
|
|
.split("\u001b[38;5;255;1m").join("\x0300") // white
|
|
.split("\u001b[38;5;250m").join("\x0F") // yellow to white
|
|
.split("\u001b[1m").join("\x0F") // normalize
|
|
.split("\u001b[0m").join("\x0F") // normalize
|
|
.split("\u000f").join("\x0F") // normalize
|
|
.split("\u001b[38;5;228;5m").join("\x0F") // normalize
|
|
.split("\u26a1").join(" ") // fick emoji
|
|
.split("\n")
|
|
if (origbody.match(/ERROR.*(location|Unbekannter)/i))
|
|
return e.reply(body[0].replace("ERROR: ", ""));
|
|
if (args.trim().match(/^moon/i))
|
|
return e.reply("ob du behindert bist.");
|
|
[body[0], body[2], body[3], body[4], body[5], body[6]].map(e.reply);
|
|
})
|
|
.catch(err => {
|
|
console.log(err);
|
|
});
|
|
}
|
|
}));
|
|
}; |