51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
import { Client } from "irc-framework";
|
|
import Weather from "./components/Weather.js";
|
|
import UrlTitle from "./components/UrlTitle.js";
|
|
import InitDB from "./components/db.js";
|
|
|
|
InitDB();
|
|
|
|
function middleware() {
|
|
return function (client, raw_events, parsed_events) {
|
|
parsed_events.use(title);
|
|
};
|
|
|
|
function title(command, event, client, next) {
|
|
if (command === "message") {
|
|
UrlTitle(event);
|
|
}
|
|
next();
|
|
}
|
|
}
|
|
|
|
const bot = new Client();
|
|
bot.use(middleware());
|
|
bot.connect({
|
|
host: "irc.libera.chat",
|
|
// host: "localhost",
|
|
nick: "g-bot",
|
|
port: 6667,
|
|
version: "grizzlys bot",
|
|
username: "g-bot",
|
|
gecos: "g-bot",
|
|
});
|
|
bot.on("registered", () => {
|
|
console.log("Connected!");
|
|
bot.join("#grizzly");
|
|
});
|
|
|
|
bot.on("close", () => {
|
|
console.log("Connection close");
|
|
});
|
|
|
|
bot.matchMessage(/^,w/, async (event) => {
|
|
return Weather(event);
|
|
});
|
|
|
|
bot.matchMessage(/^,help/, (event) => {
|
|
event.reply(",help - show this message");
|
|
event.reply(",w [location] - show weather for you city");
|
|
event.reply(",w set [location] - save your location");
|
|
event.reply(",w - after your save your location you can use ,w");
|
|
});
|