activate haitext, use mysqlsocket instead of ip
This commit is contained in:
parent
6f09ed9cf8
commit
c1dba94d75
40
index.js
Normal file → Executable file
40
index.js
Normal file → Executable file
@ -1,15 +1,14 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
const config = require('./.config.json');
|
||||
const Raven = require('raven');
|
||||
Raven.config(config.sentry).install();
|
||||
|
||||
const Irc = require("irc");
|
||||
const Irc = require("matrix-org-irc");
|
||||
const Mysql = require("mysql");
|
||||
|
||||
require('dotenv').config({path: '/home/sirx/web/w0bm.com/.env'});
|
||||
require('dotenv').config({path: '/srv/http/w0bm/.env'});
|
||||
|
||||
let db = Mysql.createPool({
|
||||
host: process.env.DB_HOST,
|
||||
socketPath: '/run/mysqld/mysqld.sock',
|
||||
user: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DATABASE,
|
||||
@ -45,11 +44,13 @@ irc.client = new Irc.Client(config.servers.n0xy.host, config.servers.n0xy.nick,
|
||||
retryDelay: 3000,
|
||||
userName: config.servers.n0xy.userName,
|
||||
realName: config.servers.n0xy.realName,
|
||||
sasl: config.servers.n0xy.sasl,
|
||||
debug: false,
|
||||
selfSigned: true,
|
||||
debugRaw: false,
|
||||
selfSigned: false,
|
||||
autoConnect: false,
|
||||
password: config.servers.n0xy.srvPassword
|
||||
password: config.servers.n0xy.srvPassword,
|
||||
channels: ["#w0bm", "#f0ck"]
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV != 'production') {
|
||||
@ -62,28 +63,11 @@ if (process.env.NODE_ENV != 'production') {
|
||||
Object.defineProperty(repl.context, "q", {get:process.exit});
|
||||
}
|
||||
|
||||
let needJoin = false;
|
||||
irc.client.addListener("registered", () => {
|
||||
console.log("registered…");
|
||||
const c = irc.client;
|
||||
//c.say("NickServ", "IDENTIFY dI0k2k7PH");
|
||||
//c.say("NickServ", "IDENTIFY jae2Loax");
|
||||
//c.say("HostServ", "ON");
|
||||
//needJoin = true;
|
||||
});
|
||||
irc.client.addListener("notice", (from, to, text) => {
|
||||
if (needJoin && from == "NickServ" && text.indexOf("Password accepted") != -1) {
|
||||
needJoin = false;
|
||||
const c = irc.client;
|
||||
//c.join("#w0bm");
|
||||
//c.join("#gz");
|
||||
}
|
||||
});
|
||||
process.nextTick(()=>irc.client.connect());
|
||||
|
||||
const handleChatCommands = require("./chatCommands")(irc, db);
|
||||
|
||||
const shiftRegex = /^(\.?\w+:?)\s+(.+)/;
|
||||
const shiftRegex = /^(\.?\w+:?)(?:\s+(.+))?/;
|
||||
//const w0bmregex = /(?:[^\/]|^|\/\/)w0bm\.com\/(?:\w+\/){0,3}([^ '\/@`´]+\.(webm)|\d+)/i;
|
||||
//const w0bmregex = /(?:[^\/]|^|\/\/)(?:b\.)?w0bm\.com\/(?:\w+\/){0,3}([^ '\/@`´]+\.(webm)|\d+)/i;
|
||||
const w0bmregex = /(?:\b(\w+)\.)?\bw0bm\.com\/(?:\w+\/){0,3}([^ '\/@`´]+\.(webm)|\d+)/i;
|
||||
@ -129,7 +113,7 @@ irc.client.addListener("message", (from, to, message, raw) => {
|
||||
if (client.opt.debug) console.log("from:", from, "to:", to, "message:", message);
|
||||
if (shiftRegex.test(message)) {
|
||||
let cmd = message.match(shiftRegex);
|
||||
let args = cmd[2].trim();
|
||||
let args = (cmd[2] || "").trim();
|
||||
cmd = cmd[1];
|
||||
|
||||
if (handleChatCommands({
|
||||
@ -214,10 +198,10 @@ if (w0bmregex.test(message)) {
|
||||
}
|
||||
}
|
||||
|
||||
/*if (~haitext.indexOf(message.toLowerCase())) {
|
||||
if (haitext.includes(message.toLowerCase())) {
|
||||
client.say(to, haitext[Math.random()*haitext.length|0] + " " + from + "!");
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
if (/^!d$/.test(message)) {
|
||||
client.say(to, from + ": the magic dice shows " + ((Math.random()*6|0)+1) + " eyes.");
|
||||
|
Loading…
Reference in New Issue
Block a user