2022-03-26 15:52:12 +00:00
|
|
|
import { Client } from "irc-framework";
|
2022-03-27 01:39:26 +00:00
|
|
|
import InitDB from "./components/db.js";
|
2022-03-26 15:52:12 +00:00
|
|
|
import Weather from "./components/Weather.js";
|
|
|
|
import UrlTitle from "./components/UrlTitle.js";
|
2022-03-27 03:01:31 +00:00
|
|
|
import Roll from "./components/Roll.js";
|
2022-03-27 01:39:26 +00:00
|
|
|
import Help from "./components/Help.js";
|
2022-03-26 20:58:59 +00:00
|
|
|
|
|
|
|
InitDB();
|
2022-03-26 15:52:12 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
});
|
|
|
|
|
2022-03-26 20:58:59 +00:00
|
|
|
bot.matchMessage(/^,w/, async (event) => {
|
2022-03-26 15:53:24 +00:00
|
|
|
return Weather(event);
|
2022-03-26 15:52:12 +00:00
|
|
|
});
|
|
|
|
|
2022-03-27 03:01:31 +00:00
|
|
|
bot.matchMessage(/^,r/, async (event) => {
|
|
|
|
return Roll(event);
|
|
|
|
});
|
|
|
|
|
2022-03-26 15:52:12 +00:00
|
|
|
bot.matchMessage(/^,help/, (event) => {
|
2022-03-27 01:39:26 +00:00
|
|
|
return Help(event);
|
2022-03-26 15:52:12 +00:00
|
|
|
});
|