<commit_before>//var sqlite3 = require('sqlite3'); // sqlite3 doesn't like to be hotpatched so we load it as a global in app.js instead
var db = new sqlite3.Database('config/users.db', function() {
	db.run("CREATE TABLE if not exists users (userid TEXT, name TEXT, bucks INTEGER)");
});

var fs = require('fs');
var http = require('http');
var MD5 = require('MD5');
var shopTitle = 'Luster Shop';
var serverIp = '172.16.58.3';

var prices = {
	"customsymbol": 5,
	"leagueroom": 5,
	"fix": 10,
	"declare": 15,
	"poof": 20,
	"customavatar": 25,
	"animatedavatar": 35,
	"infobox": 40,
	"leagueshop": 55,
	"chatroom": 70,
};

function readMoney(userid, callback) {
	if (!callback) return false;
	userid = toId(userid);
	db.all("SELECT * FROM users WHERE userid=$userid", {$userid: userid}, function(err,rows) {
		if (err) return console.log(err);
		callback((rows[0] ? rows[0].bucks : 0));
	});
}
global.readMoney = readMoney;

function writeMoney(userid, amount, callback) {
	userid = toId(userid);
	db.all("SELECT * FROM users WHERE userid=$userid", {$userid: userid}, function(err,rows) {
		if (rows.length < 1) {
			db.run("INSERT INTO users(userid, bucks) VALUES ($userid, $amount)", {$userid: userid, $amount: amount}, function(err) {
				if (err) return console.log(err);
				if (callback) callback();
			});
		} else {
			amount += rows[0].bucks;
			db.run("UPDATE users SET bucks=$amount WHERE userid=$userid", {$amount: amount, $userid: userid}, function(err) {
				if (err) return console.log(err);
				if (callback) callback();
			});
		}
	});
}
global.writeMoney = writeMoney;

function logTransaction (message) {
	if (!message) return false;
	fs.appendFile('logs/transactions.log','['+new Date().toUTCString()+'] '+message+'\n');
}
global.logTransaction = logTransaction;

function logDice (message) {
	if (!message) return false;
	fs.appendFile('logs/dice.log','['+new Date().toUTCString()+'] '+message+'\n');
}

function messageSeniorStaff (message) {
	for (var u in Users.users) {
		if (!Users.users[u].connected || !Users.users[u].can('declare')) continue;
		Users.users[u].send('|pm|~Server|'+Users.users[u].getIdentity()+'|'+message);
	}
}
<commit_msg>Send shop messages to staff<commit_after>//var sqlite3 = require('sqlite3'); // sqlite3 doesn't like to be hotpatched so we load it as a global in app.js instead
var db = new sqlite3.Database('config/users.db', function() {
	db.run("CREATE TABLE if not exists users (userid TEXT, name TEXT, bucks INTEGER)");
});

var fs = require('fs');
var http = require('http');
var MD5 = require('MD5');
var shopTitle = 'Luster Shop';
var serverIp = '172.16.58.3';

var prices = {
	"customsymbol": 5,
	"leagueroom": 5,
	"fix": 10,
	"declare": 15,
	"poof": 20,
	"customavatar": 0,
	"animatedavatar": 0,
	"infobox": 0,
	"leagueshop": 55,
	"chatroom": 100,
};

function readMoney(userid, callback) {
	if (!callback) return false;
	userid = toId(userid);
	db.all("SELECT * FROM users WHERE userid=$userid", {$userid: userid}, function(err,rows) {
		if (err) return console.log(err);
		callback((rows[0] ? rows[0].bucks : 0));
	});
}
global.readMoney = readMoney;

function writeMoney(userid, amount, callback) {
	userid = toId(userid);
	db.all("SELECT * FROM users WHERE userid=$userid", {$userid: userid}, function(err,rows) {
		if (rows.length < 1) {
			db.run("INSERT INTO users(userid, bucks) VALUES ($userid, $amount)", {$userid: userid, $amount: amount}, function(err) {
				if (err) return console.log(err);
				if (callback) callback();
			});
		} else {
			amount += rows[0].bucks;
			db.run("UPDATE users SET bucks=$amount WHERE userid=$userid", {$amount: amount, $userid: userid}, function(err) {
				if (err) return console.log(err);
				if (callback) callback();
			});
		}
	});
}
global.writeMoney = writeMoney;

function logTransaction (message) {
	if (!message) return false;
	fs.appendFile('logs/transactions.log','['+new Date().toUTCString()+'] '+message+'\n');
}
global.logTransaction = logTransaction;

function logDice (message) {
	if (!message) return false;
	fs.appendFile('logs/dice.log','['+new Date().toUTCString()+'] '+message+'\n');
}

function messageSeniorStaff (message) {
	for (var u in Users.users) {
		if (!Users.users[u].connected || !Users.users[u].can('declare')) continue;
		Users.users[u].send('|pm|~Server|'+Users.users[u].getIdentity()+'|'+message);
		Rooms('staff').addRaw('<font color="red"><b>SHOP:</b></font> ' + Tools.escapeHTML(message));
		Rooms('staff').update();
	}
}

{'fraction_non_alphanumeric': 0.1919463087248322, 'fraction_numerical': 0.016107382550335572, 'mean_word_length': 4.993297587131368, 'pattern_counts': {'":': 20, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6308179', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1562, 'n_words': 396}