irc file uploads
This commit is contained in:
parent
596725043a
commit
530b2f3775
104
client.js
104
client.js
|
@ -6,6 +6,7 @@ const formdata = require("form-data");
|
||||||
const he = require("he");
|
const he = require("he");
|
||||||
const cheerio = require("cheerio");
|
const cheerio = require("cheerio");
|
||||||
const sharp = require("sharp");
|
const sharp = require("sharp");
|
||||||
|
const crypto = require("crypto");
|
||||||
const { createCanvas, loadImage } = require("canvas");
|
const { createCanvas, loadImage } = require("canvas");
|
||||||
var mmm = require("mmmagic");
|
var mmm = require("mmmagic");
|
||||||
var Magic = mmm.Magic;
|
var Magic = mmm.Magic;
|
||||||
|
@ -22,12 +23,15 @@ const mc_options = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const name = "rena_chan";
|
const name = "rena_chan";
|
||||||
const password = "no";
|
const password = "fuck";
|
||||||
const irc_password = "no";
|
const irc_password = "you";
|
||||||
const yt_token = "no"
|
const irc_rena_password = "stupid";
|
||||||
|
const yt_token = "cunt"
|
||||||
const irc_ip = "192.168.0.152";
|
const irc_ip = "192.168.0.152";
|
||||||
|
const upload_folder = "/var/www/html/u/uploads/";
|
||||||
const mc_bridge_enabled = false;
|
const mc_bridge_enabled = false;
|
||||||
const irc_bridge_enabled = true;
|
const irc_bridge_enabled = true;
|
||||||
|
const do_file_upload = false;
|
||||||
var scraper = "google_cse";
|
var scraper = "google_cse";
|
||||||
const instance = "https://4get.lumaeris.com";
|
const instance = "https://4get.lumaeris.com";
|
||||||
|
|
||||||
|
@ -122,6 +126,29 @@ http_bullshit.listen(6969, "0.0.0.0", function(){
|
||||||
/*
|
/*
|
||||||
Helper functions
|
Helper functions
|
||||||
*/
|
*/
|
||||||
|
function rot13(str){
|
||||||
|
|
||||||
|
return str.replace(/[a-zA-Z]/g, (char) => {
|
||||||
|
|
||||||
|
const charCode = char.charCodeAt(0);
|
||||||
|
|
||||||
|
if(char >= 'a' && char <= 'z'){
|
||||||
|
|
||||||
|
return String.fromCharCode(((charCode - 97 + 13) % 26) + 97);
|
||||||
|
}else if(char >= 'A' && char <= 'Z') {
|
||||||
|
|
||||||
|
return String.fromCharCode(((charCode - 65 + 13) % 26) + 65);
|
||||||
|
}
|
||||||
|
|
||||||
|
return char; // Non-alphabet characters remain unchanged
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function sha1(str){
|
||||||
|
|
||||||
|
return crypto.createHash("sha1").update(str).digest("hex");
|
||||||
|
}
|
||||||
|
|
||||||
async function getmime(file){
|
async function getmime(file){
|
||||||
|
|
||||||
return new Promise(function(resolve, reject){
|
return new Promise(function(resolve, reject){
|
||||||
|
@ -568,26 +595,39 @@ function init_irc(){
|
||||||
channels: [
|
channels: [
|
||||||
"#deekchat"
|
"#deekchat"
|
||||||
],
|
],
|
||||||
userName: "rena_chan",
|
userName: name,
|
||||||
realName: "Rena Chan",
|
realName: "Rena Chan",
|
||||||
autoRejoin: false,
|
autoRejoin: true,
|
||||||
retryCount: 0
|
retryCount: 1000,
|
||||||
|
password: irc_password
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
irc_client.addListener("join#deekchat", function(){
|
irc_client.addListener("join#deekchat", function(nick){
|
||||||
|
|
||||||
console.log("Connected to IRC server on #deekchat");
|
if(nick === name){
|
||||||
irc_logged_in = true;
|
|
||||||
|
|
||||||
irc_client.say("NickServ", "IDENTIFY rena_chan " + irc_password);
|
|
||||||
irc_client.send("OPER", "rena_chan", irc_password);
|
|
||||||
|
|
||||||
// add debounce so we dont send missed messages
|
|
||||||
setTimeout(function(){
|
|
||||||
|
|
||||||
irc_debounce = true;
|
console.log("Connected to IRC server on #deekchat");
|
||||||
}, 2500);
|
irc_logged_in = true;
|
||||||
|
|
||||||
|
irc_client.send("OPER", name, irc_rena_password);
|
||||||
|
|
||||||
|
// add debounce so we dont send missed messages
|
||||||
|
setTimeout(function(){
|
||||||
|
|
||||||
|
irc_debounce = true;
|
||||||
|
}, 2500);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// someone joined the channel
|
||||||
|
irc_client.say(nick, "Welcome you ball sucker, here's your file upload link");
|
||||||
|
irc_client.say(
|
||||||
|
nick,
|
||||||
|
"https://lolcat.ca/u/upload" +
|
||||||
|
"?u=" + nick +
|
||||||
|
"&h=" + sha1(rot13(irc_password.toUpperCase()) + nick)
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
irc_client.addListener("message", function(from, to, message){
|
irc_client.addListener("message", function(from, to, message){
|
||||||
|
@ -629,8 +669,6 @@ function init_irc(){
|
||||||
irc_logged_in = false;
|
irc_logged_in = false;
|
||||||
irc_debounce = false;
|
irc_debounce = false;
|
||||||
//irc_client.disconnect();
|
//irc_client.disconnect();
|
||||||
|
|
||||||
init_irc();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
irc_client.addListener("error", function(error){
|
irc_client.addListener("error", function(error){
|
||||||
|
@ -642,6 +680,34 @@ function init_irc(){
|
||||||
|
|
||||||
init_irc();
|
init_irc();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Watch for file uploads
|
||||||
|
*/
|
||||||
|
fs.watch(upload_folder, async function(event, filename){
|
||||||
|
|
||||||
|
if(
|
||||||
|
event != "rename" ||
|
||||||
|
typeof filename != "string"
|
||||||
|
){
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var path = upload_folder + filename;
|
||||||
|
var parts = filename.split(".");
|
||||||
|
|
||||||
|
var username = parts[0];
|
||||||
|
|
||||||
|
if(fs.existsSync(path)){
|
||||||
|
|
||||||
|
fs.readFile(path, function(err, data){
|
||||||
|
|
||||||
|
send(-1, "<" + username + "> [file]", data);
|
||||||
|
fs.unlink(path, function(err){});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
User defined FUN-ctions!!!
|
User defined FUN-ctions!!!
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue